LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::PrinterForTypes< Args > Class Template Reference

#include "Printer.h"

Public Member Functions

 PrinterForTypes ()
 
std::string help_message () const
 
void value_for_atom (fhicl::ParameterSet const &pset, std::string const &cpp_type, std::string const &key) const
 
void value_for_sequence (fhicl::ParameterSet const &pset, std::string const &cpp_type, std::string const &key) const
 
cet::exempt_ptr< Printer const > get_ (std::string const &cpp_type) const
 

Public Attributes

std::map< std::string, std::unique_ptr< Printer > > printers_
 

Detailed Description

template<typename... Args>
class fhicl::PrinterForTypes< Args >

Definition at line 75 of file Printer.h.

Constructor & Destructor Documentation

template<typename... Args>
fhicl::PrinterForTypes< Args >::PrinterForTypes ( )
inline

Definition at line 77 of file Printer.h.

78  {
79  (printers_.emplace(detail::name_of<Args>(),
80  std::make_unique<PrinterFor<Args>>()),
81  ...);
82  }
std::map< std::string, std::unique_ptr< Printer > > printers_
Definition: Printer.h:123

Member Function Documentation

template<typename... Args>
cet::exempt_ptr<Printer const> fhicl::PrinterForTypes< Args >::get_ ( std::string const &  cpp_type) const
inline

Definition at line 113 of file Printer.h.

References util::cend().

114  {
115  if (auto it = printers_.find(cpp_type); it != cend(printers_)) {
116  return it->second.get();
117  }
118  throw cet::exception{"Usage error"} << "The specified type '" << cpp_type
119  << "' is not supported.\n"
120  << help_message();
121  }
std::map< std::string, std::unique_ptr< Printer > > printers_
Definition: Printer.h:123
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:93
std::string help_message() const
Definition: Printer.h:85
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename... Args>
std::string fhicl::PrinterForTypes< Args >::help_message ( ) const
inline

Definition at line 85 of file Printer.h.

86  {
87  std::string result{"Supported types include:\n"};
88  for (auto const& pr : printers_) {
89  result += " '";
90  result += pr.first;
91  result += "'\n";
92  }
93  return result;
94  }
std::map< std::string, std::unique_ptr< Printer > > printers_
Definition: Printer.h:123
template<typename... Args>
void fhicl::PrinterForTypes< Args >::value_for_atom ( fhicl::ParameterSet const &  pset,
std::string const &  cpp_type,
std::string const &  key 
) const
inline

Definition at line 97 of file Printer.h.

100  {
101  get_(cpp_type)->print_as_atom(pset, key);
102  }
cet::exempt_ptr< Printer const > get_(std::string const &cpp_type) const
Definition: Printer.h:113
template<typename... Args>
void fhicl::PrinterForTypes< Args >::value_for_sequence ( fhicl::ParameterSet const &  pset,
std::string const &  cpp_type,
std::string const &  key 
) const
inline

Definition at line 105 of file Printer.h.

108  {
109  get_(cpp_type)->print_as_sequence(pset, key);
110  }
cet::exempt_ptr< Printer const > get_(std::string const &cpp_type) const
Definition: Printer.h:113

Member Data Documentation

template<typename... Args>
std::map<std::string, std::unique_ptr<Printer> > fhicl::PrinterForTypes< Args >::printers_

Definition at line 123 of file Printer.h.


The documentation for this class was generated from the following file: