ServiceTable.cxx
Go to the documentation of this file.
1 ///
2 /// \file EventDisplayBase/ServiceTable.h
3 /// \brief Interface to services and their configurations
4 /// \author messier@indiana.edu
5 ///
6 #include "nutools/EventDisplayBase/ServiceTable.h"
7 
11 
12 #include "nutools/EventDisplayBase/ParameterSetEdit.h"
13 #include "nutools/EventDisplayBase/ParameterSetEditDialog.h"
14 
15 #include <iostream>
16 
17 using namespace evdb;
18 
19 std::map<std::string, int> ServiceTable::fgCategoryOverrides;
20 
21 //......................................................................
22 
24 {
25  if(fgCategoryOverrides.count(s))
27 
28  return (s.find("DrawingOptions")!=std::string::npos);
29 }
30 
31 //......................................................................
32 
35 {
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  s.fParamSet.clear();
82  s.fService->do_reconfigure(pset);
83  s.fCurrentParamSet = pset;
84  }
85  catch (fhicl::exception const& e) {
86  MF_LOG_ERROR("ServiceTable") << "Error parsing the new configuration:\n"
87  << e
88  << "\nRe-configuration has been ignored for service: "
89  << s.fName;
90  }
91  }
92 }
93 
94 //......................................................................
95 
96 void ServiceTable::OverrideCategory(std::string const& s, int const cat)
97 {
98  fgCategoryOverrides[s] = cat;
99 }
100 
101 //......................................................................
102 
104 {
105  assert(id < fServices.size());
106  return fServices[id].fCurrentParamSet;
107 }
108 
109 //......................................................................
110 
112 
113 ////////////////////////////////////////////////////////////////////////
void RegisterService(fhicl::ParameterSet const &ps, cet::exempt_ptr< Reconfigurable > s)
static constexpr int kDRAWING_SERVICE
Definition: ServiceTable.h:19
QList< Entry > entry
static ServiceTable & Instance()
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12
Collection of Services used in the event display.
Definition: ServiceTable.h:36
cet::exempt_ptr< Reconfigurable > fService
Definition: ServiceTable.h:30
static std::map< std::string, int > fgCategoryOverrides
Definition: ServiceTable.h:53
#define MF_LOG_ERROR(category)
void Edit(unsigned int i)
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
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.
const double e
def move(depos, offset)
Definition: depos.py:107
T get(std::string const &key) const
Definition: ParameterSet.h:231
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
static QCString * s
Definition: config.cpp:1042
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33