1 #ifndef tools_Printer_h 2 #define tools_Printer_h 5 #include "cetlib_except/demangle.h" 6 #include "cetlib_except/exception.h" 44 std::cout << pset.
get<
T>(
key) <<
'\n';
51 auto const entries = pset.
get<std::vector<T>>(
key);
52 for (
auto const&
entry : entries) {
53 std::cout <<
entry <<
'\n';
63 return cet::demangle_symbol(
typeid(
T).
name());
68 name_of<std::string>()
74 template <
typename... Args>
79 (printers_.emplace(detail::name_of<Args>(),
88 for (
auto const& pr : printers_) {
101 get_(cpp_type)->print_as_atom(pset, key);
109 get_(cpp_type)->print_as_sequence(pset, key);
115 if (
auto it = printers_.find(cpp_type); it !=
cend(printers_)) {
116 return it->second.get();
118 throw cet::exception{
"Usage error"} <<
"The specified type '" << cpp_type
119 <<
"' is not supported.\n" 123 std::map<std::string, std::unique_ptr<Printer>>
printers_;
std::map< std::string, std::unique_ptr< Printer > > printers_
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
void value_for_sequence(fhicl::ParameterSet const &pset, std::string const &cpp_type, std::string const &key) const
void print_as_sequence(fhicl::ParameterSet const &pset, std::string const &key) const
void print_as_atom(fhicl::ParameterSet const &pset, std::string const &key) const
void do_sequence_print(fhicl::ParameterSet const &pset, std::string const &key) const
std::string help_message() const
cet::exempt_ptr< Printer const > get_(std::string const &cpp_type) const
T get(std::string const &key) const
virtual ~Printer()=default
virtual void do_sequence_print(fhicl::ParameterSet const &pset, std::string const &key) const =0
virtual void do_atomic_print(fhicl::ParameterSet const &pset, std::string const &key) const =0
void do_atomic_print(fhicl::ParameterSet const &pset, std::string const &key) const
void value_for_atom(fhicl::ParameterSet const &pset, std::string const &cpp_type, std::string const &key) const
cet::coded_exception< error, detail::translate > exception