ServiceTable.h
Go to the documentation of this file.
1 #ifndef art_Framework_Services_Registry_ServiceTable_h
2 #define art_Framework_Services_Registry_ServiceTable_h
3 // vim: set sw=2 expandtab :
4 
5 #include "cetlib/exempt_ptr.h"
7 #include "fhiclcpp/types/Table.h"
9 
10 #include <ostream>
11 #include <set>
12 #include <sstream>
13 #include <string>
14 #include <utility>
15 
16 namespace fhicl {
17 
18  class ParameterSet;
19 
20 } // namespace fhicl
21 
22 namespace art {
23 
24  template <typename T>
26 
27  public: // MEMBER FUNCTIONS -- Special Member Functions
28  explicit ServiceTable(fhicl::Name&& name) : config_{std::move(name)} {}
29 
31  : config_{fhicl::Name{"<service>"}}
32  {
33  std::set<std::string> const keys_to_ignore{"service_type",
34  "service_provider"};
35  config_.validate(pset, keys_to_ignore);
36  }
37 
38  public: // MEMBER FUNCTIONS -- API for the user
39  fhicl::ParameterSet const&
40  get_PSet() const
41  {
42  return config_.get_PSet();
43  }
44 
45  void
46  print_allowed_configuration(std::ostream& os,
47  std::string const& prefix) const
48  {
49  config_.print_allowed_configuration(os, prefix);
50  }
51 
52  auto const&
53  operator()() const
54  {
55  return config_();
56  }
57 
58  private: // MEMBER FUNCTIONS -- Implementation details
60  get_parameter_base() const override
61  {
62  return &config_;
63  }
64 
65  private: // MEMBER DATA
67  };
68 
69  template <typename T>
70  inline std::ostream&
71  operator<<(std::ostream& os, ServiceTable<T> const& t)
72  {
73  std::ostringstream config;
74  t.print_allowed_configuration(config, std::string(3, ' '));
75  return os << config.str();
76  }
77 
78 } // namespace art
79 
80 #endif /* art_Framework_Services_Registry_ServiceTable_h */
81 
82 // Local variables:
83 // mode: c++
84 // End:
static QCString name
Definition: declinfo.cpp:673
auto const & operator()() const
Definition: ServiceTable.h:53
fhicl::Table< T > config_
Definition: ServiceTable.h:66
std::string string
Definition: nybbler.cc:12
void print_allowed_configuration(std::ostream &os, std::string const &prefix) const
Definition: ServiceTable.h:46
ServiceTable(fhicl::ParameterSet const &pset)
Definition: ServiceTable.h:30
cet::exempt_ptr< fhicl::detail::ParameterBase const > get_parameter_base() const override
Definition: ServiceTable.h:60
static Config * config
Definition: config.cpp:1054
ServiceTable(fhicl::Name &&name)
Definition: ServiceTable.h:28
def move(depos, offset)
Definition: depos.py:107
fhicl::ParameterSet const & get_PSet() const
Definition: ServiceTable.h:40