All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DumpAssociations.h
Go to the documentation of this file.
1 /**
2  * @file DumpAssociations.h
3  * @brief Dumps on a stream the content of associations
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date September 25th, 2015
6  */
7 
8 #ifndef UTIL_DUMPASSOCIATIONS_H
9 #define UTIL_DUMPASSOCIATIONS_H 1
10 
11 // C//C++ standard libraries
12 #include <typeinfo>
13 #include <type_traits> // std::is_same<>
14 
15 // framework and supporting libraries
16 #include "cetlib_except/demangle.h"
17 #include "canvas/Persistency/Common/Assns.h"
18 
19 
20 namespace util {
21 
22  /**
23  * @brief Dumps a short introduction about specified association
24  * @tparam Stream type of output stream
25  * @tparam Left first type in the association
26  * @tparam Right second type in the association
27  * @tparam Data metadata type in the association
28  * @param out output stream
29  * @param assns the associations to be dumped
30  */
31  template <typename Stream, typename Left, typename Right, typename Data>
33  (Stream&& out, art::Assns<Left, Right, Data> const& assns)
34  {
35  out << "Association between '" << cet::demangle_symbol(typeid(Left).name())
36  << "' and '" << cet::demangle_symbol(typeid(Right).name()) << "'";
37  if (std::is_same<Data, void>()) {
38  out << " with '" << cet::demangle_symbol(typeid(Data).name())
39  << "' metadata";
40  }
41  if (assns.size() > 0) {
42  out << " contains " << assns.size() << " relations";
43  }
44  else {
45  out << " is empty";
46  }
47  } // DumpAssociationsIntro<Data>()
48 
49 
50 
51 } // namespace util
52 
53 #endif // UTIL_DUMPASSOCIATIONS_H
void DumpAssociationsIntro(Stream &&out, art::Assns< Left, Right, Data > const &assns)
Dumps a short introduction about specified association.
then echo fcl name
bnb BNB Stream