Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
nutools
old
EventDisplayBase
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
8
#include "
fhiclcpp/intermediate_table.h
"
9
#include "
fhiclcpp/make_ParameterSet.h
"
10
#include "
messagefacility/MessageLogger/MessageLogger.h
"
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
23
bool
ServiceTable::IsDrawingService
(
const
std::string
&
s
)
24
{
25
if
(
fgCategoryOverrides
.count(s))
26
return
fgCategoryOverrides
[s] ==
kDRAWING_SERVICE
;
27
28
return
(s.find(
"DrawingOptions"
)!=std::string::npos);
29
}
30
31
//......................................................................
32
33
void
ServiceTable::RegisterService
(
fhicl::ParameterSet
const
&
ps
,
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
=
""
;
40
entry.
fCategory
= this->
IsDrawingService
(entry.
fName
) ?
kDRAWING_SERVICE
:
kEXPERIMENT_SERVICE
;
41
entry.
fService
=
s
;
42
43
fServices
.emplace_back(
std::move
(entry));
44
}
45
46
//......................................................................
47
48
ServiceTable
&
ServiceTable::Instance
()
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());
59
new
ParameterSetEditDialog
(i);
60
}
61
62
//......................................................................
63
64
void
ServiceTable::ApplyEdits
()
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
{
76
fhicl::ParameterSet
pset;
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
103
fhicl::ParameterSet
const
&
ServiceTable::GetParameterSet
(
unsigned
int
id
)
const
104
{
105
assert(
id
<
fServices
.size());
106
return
fServices
[id].fCurrentParamSet;
107
}
108
109
//......................................................................
110
111
ServiceTable::ServiceTable
() {}
112
113
////////////////////////////////////////////////////////////////////////
evdb::ServiceTable::RegisterService
void RegisterService(fhicl::ParameterSet const &ps, cet::exempt_ptr< Reconfigurable > s)
Definition:
ServiceTable.cxx:33
evdb::kDRAWING_SERVICE
static constexpr int kDRAWING_SERVICE
Definition:
ServiceTable.h:19
entry
QList< Entry > entry
Definition:
tclscanner.cpp:1150
evdb::ServiceTable::Instance
static ServiceTable & Instance()
Definition:
ServiceTable.cxx:48
intermediate_table.h
genie::units::ps
static const double ps
Definition:
Units.h:103
string
std::string string
Definition:
nybbler.cc:12
evdb::ServiceTable
Collection of Services used in the event display.
Definition:
ServiceTable.h:36
evdb::ServiceTableEntry::fService
cet::exempt_ptr< Reconfigurable > fService
Definition:
ServiceTable.h:30
make_ParameterSet.h
evdb::ServiceTable::fgCategoryOverrides
static std::map< std::string, int > fgCategoryOverrides
Definition:
ServiceTable.h:53
MF_LOG_ERROR
#define MF_LOG_ERROR(category)
Definition:
MessageLogger.h:229
evdb::ServiceTable::Edit
void Edit(unsigned int i)
Definition:
ServiceTable.cxx:56
fhicl::make_ParameterSet
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
Definition:
make_ParameterSet.cc:30
evdb
Manage all things related to colors for the event display.
Definition:
Edge3DDrawer_tool.cc:10
MessageLogger.h
evdb::ServiceTable::ServiceTable
ServiceTable()
Definition:
ServiceTable.cxx:111
evdb::ServiceTableEntry::fParamSet
std::string fParamSet
Definition:
ServiceTable.h:28
evdb::ServiceTableEntry::fName
std::string fName
Definition:
ServiceTable.h:26
evdb::kEXPERIMENT_SERVICE
static constexpr int kEXPERIMENT_SERVICE
Definition:
ServiceTable.h:20
evdb::ServiceTable::IsDrawingService
static bool IsDrawingService(std::string const &s)
Definition:
ServiceTable.cxx:23
evdb::ParameterSetEditDialog
Top-level interface to all parameter sets.
Definition:
ParameterSetEditDialog.h:201
e
const double e
Definition:
gUpMuFluxGen.cxx:165
wirecell.gen.depos.move
def move(depos, offset)
Definition:
depos.py:107
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:231
evdb::ServiceTable::fServices
std::vector< ServiceTableEntry > fServices
Definition:
ServiceTable.h:50
cet::exempt_ptr
Definition:
exempt_ptr.h:41
evdb::ServiceTable::ApplyEdits
void ApplyEdits()
Definition:
ServiceTable.cxx:64
MF_LOG_DEBUG
#define MF_LOG_DEBUG(id)
Definition:
MessageLogger.h:268
evdb::ServiceTable::GetParameterSet
fhicl::ParameterSet const & GetParameterSet(unsigned int i) const
Definition:
ServiceTable.cxx:103
evdb::ServiceTableEntry::fCurrentParamSet
fhicl::ParameterSet fCurrentParamSet
Definition:
ServiceTable.h:27
evdb::ServiceTable::OverrideCategory
static void OverrideCategory(std::string const &s, int cat)
Definition:
ServiceTable.cxx:96
evdb::ServiceTableEntry::fCategory
int fCategory
Definition:
ServiceTable.h:29
evdb::ServiceTableEntry
Information about a service required by the event display.
Definition:
ServiceTable.h:25
s
static QCString * s
Definition:
config.cpp:1042
fhicl::exception
cet::coded_exception< error, detail::translate > exception
Definition:
exception.h:33
fhicl::ParameterSet
Definition:
ParameterSet.h:34
Generated by
1.8.11