LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ServiceTable.cxx
Go to the documentation of this file.
7 
9 //#include "fhiclcpp/make_ParameterSet.h"
11 
14 
15 #include <iostream>
16 
17 using namespace evdb;
18 
19 std::map<std::string, int> ServiceTable::fgCategoryOverrides;
20 
21 //......................................................................
22 
23 bool ServiceTable::IsDrawingService(const std::string& s)
24 {
25  if(fgCategoryOverrides.count(s))
27 
28  return (s.find("DrawingOptions")!=std::string::npos);
29 }
30 
31 //......................................................................
32 
34  cet::exempt_ptr<Reconfigurable> s)
35 {
36  ServiceTableEntry entry;
37  entry.fName = ps.get<std::string>("service_type");
38  entry.fCurrentParamSet = ps;
39  entry.fParamSet = "";
41  entry.fService = s;
42 
43  fServices.emplace_back(std::move(entry));
44 }
45 
46 //......................................................................
47 
49 {
50  static ServiceTable s;
51  return s;
52 }
53 
54 //......................................................................
55 
56 void ServiceTable::Edit(unsigned int i)
57 {
58  assert(i < fServices.size());
60 }
61 
62 //......................................................................
63 
65 {
66  // Look to see if we have any new service configurations to apply
67  for (auto& s : fServices) {
68  if (s.fParamSet.empty()) continue;
69 
70  MF_LOG_DEBUG("ServiceTable") << "Applying edits for "
71  << s.fName
72  << "\n"
73  << s.fParamSet;
74 
75  try {
77  //
78  // Each of the next 2 lines may throw on error: should check.
79  //
80  //fhicl::make_ParameterSet(s.fParamSet, pset);
81  pset = fhicl::ParameterSet::make(s.fParamSet);
82  s.fParamSet.clear();
83  s.fService->do_reconfigure(pset);
84  s.fCurrentParamSet = pset;
85  }
86  catch (fhicl::exception const& e) {
87  MF_LOG_ERROR("ServiceTable") << "Error parsing the new configuration:\n"
88  << e
89  << "\nRe-configuration has been ignored for service: "
90  << s.fName;
91  }
92  }
93 }
94 
95 //......................................................................
96 
97 void ServiceTable::OverrideCategory(std::string const& s, int const cat)
98 {
99  fgCategoryOverrides[s] = cat;
100 }
101 
102 //......................................................................
103 
105 {
106  assert(id < fServices.size());
107  return fServices[id].fCurrentParamSet;
108 }
109 
110 //......................................................................
111 
113 
void RegisterService(fhicl::ParameterSet const &ps, cet::exempt_ptr< Reconfigurable > s)
static constexpr int kDRAWING_SERVICE
Definition: ServiceTable.h:19
static ServiceTable & Instance()
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
Collection of Services used in the event display.
Definition: ServiceTable.h:36
cet::exempt_ptr< Reconfigurable > fService
Definition: ServiceTable.h:30
Interface to services and their configurations.
static std::map< std::string, int > fgCategoryOverrides
Definition: ServiceTable.h:53
#define MF_LOG_ERROR(category)
void Edit(unsigned int i)
Manage all things related to colors for the event display.
static constexpr int kEXPERIMENT_SERVICE
Definition: ServiceTable.h:20
static bool IsDrawingService(std::string const &s)
Top-level interface to all parameter sets.
T get(std::string const &key) const
Definition: ParameterSet.h:314
Pop-up window for editing parameter sets.
std::vector< ServiceTableEntry > fServices
Definition: ServiceTable.h:50
#define MF_LOG_DEBUG(id)
fhicl::ParameterSet const & GetParameterSet(unsigned int i) const
fhicl::ParameterSet fCurrentParamSet
Definition: ServiceTable.h:27
static void OverrideCategory(std::string const &s, int cat)
Information about a service required by the event display.
Definition: ServiceTable.h:25
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33