otsdaq  v2_04_01
Configurable.cc
1 #include "otsdaq-core/Configurable/Configurable.h"
2 
3 #include "otsdaq-core/TablePlugins/XDAQContextTable.h"
4 
5 using namespace ots;
6 
7 //==============================================================================
8 Configurable::Configurable(const ConfigurationTree& theXDAQContextConfigTree,
9  const std::string& theConfigurationPath)
10  : theXDAQContextConfigTree_(theXDAQContextConfigTree)
11  , theConfigurationPath_(theConfigurationPath)
12  , theConfigurationRecordName_(
13  theXDAQContextConfigTree_.getNode(theConfigurationPath_).getValueAsString())
14 {
15  __CFG_COUT__ << " Configurable class constructed. " << __E__;
16 }
17 
18 //==============================================================================
19 Configurable::~Configurable(void) {}
20 
21 //==============================================================================
22 ConfigurationTree Configurable::getSelfNode() const
23 {
24  // Note: do not save self node as member, because it may change as configuration is
25  // activated
26  return theXDAQContextConfigTree_.getNode(theConfigurationPath_);
27 }
28 
29 //==============================================================================
30 const ConfigurationManager* Configurable::getConfigurationManager() const
31 {
32  return theXDAQContextConfigTree_.getConfigurationManager();
33 }
34 
35 //==============================================================================
36 const std::string& Configurable::getContextUID() const
37 {
38  return theXDAQContextConfigTree_
39  .getForwardNode(theConfigurationPath_, 1 /*steps to xdaq node*/)
40  .getValueAsString();
41 }
42 
43 //==============================================================================
44 const std::string& Configurable::getApplicationUID() const
45 {
46  return theXDAQContextConfigTree_
47  .getForwardNode(theConfigurationPath_, 3 /*steps to app node*/)
48  .getValueAsString();
49 }
50 
51 //==============================================================================
52 unsigned int Configurable::getApplicationLID() const
53 {
54  const XDAQContextTable* contextConfig =
55  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
56 
57  return contextConfig
58  ->getApplicationNode(
59  getConfigurationManager(), getContextUID(), getApplicationUID())
60  .getNode(contextConfig->colApplication_.colId_)
61  .getValue<unsigned int>();
62 }
63 
64 //==============================================================================
65 std::string Configurable::getContextAddress() const
66 {
67  const XDAQContextTable* contextConfig =
68  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
69 
70  return contextConfig->getContextNode(getConfigurationManager(), getContextUID())
71  .getNode(contextConfig->colContext_.colAddress_)
72  .getValue<std::string>();
73 }
74 
75 //==============================================================================
76 unsigned int Configurable::getContextPort() const
77 {
78  const XDAQContextTable* contextConfig =
79  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
80 
81  return contextConfig->getContextNode(getConfigurationManager(), getContextUID())
82  .getNode(contextConfig->colContext_.colPort_)
83  .getValue<unsigned int>();
84 }