otsdaq  v2_03_00
Configurable.cc
1 #include "otsdaq-core/Configurable/Configurable.h"
2 
3 #include "otsdaq-core/TablePluginDataFormats/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  , selfNode_(theXDAQContextConfigTree_.getNode(theConfigurationPath_))
15 {
16  __CFG_COUT__ << " Configurable class constructed. " << __E__;
17 }
18 
19 //==============================================================================
20 Configurable::~Configurable(void) {}
21 
22 //==============================================================================
23 const ConfigurationTree& Configurable::getSelfNode() const
24 {
25  return selfNode_; // theXDAQContextConfigTree_.getNode(theConfigurationPath_);
26 }
27 
28 //==============================================================================
29 const ConfigurationManager* Configurable::getConfigurationManager() const
30 {
31  return theXDAQContextConfigTree_.getConfigurationManager();
32 }
33 
34 //==============================================================================
35 const std::string& Configurable::getContextUID() const
36 {
37  return theXDAQContextConfigTree_
38  .getForwardNode(theConfigurationPath_, 1 /*steps to xdaq node*/)
39  .getValueAsString();
40 }
41 
42 //==============================================================================
43 const std::string& Configurable::getApplicationUID() const
44 {
45  return theXDAQContextConfigTree_
46  .getForwardNode(theConfigurationPath_, 3 /*steps to app node*/)
47  .getValueAsString();
48 }
49 
50 //==============================================================================
51 unsigned int Configurable::getApplicationLID() const
52 {
53  const XDAQContextTable* contextConfig =
54  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
55 
56  return contextConfig
57  ->getApplicationNode(
58  getConfigurationManager(), getContextUID(), getApplicationUID())
59  .getNode(contextConfig->colApplication_.colId_)
60  .getValue<unsigned int>();
61 }
62 
63 //==============================================================================
64 std::string Configurable::getContextAddress() const
65 {
66  const XDAQContextTable* contextConfig =
67  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
68 
69  return contextConfig->getContextNode(getConfigurationManager(), getContextUID())
70  .getNode(contextConfig->colContext_.colAddress_)
71  .getValue<std::string>();
72 }
73 
74 //==============================================================================
75 unsigned int Configurable::getContextPort() const
76 {
77  const XDAQContextTable* contextConfig =
78  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
79 
80  return contextConfig->getContextNode(getConfigurationManager(), getContextUID())
81  .getNode(contextConfig->colContext_.colPort_)
82  .getValue<unsigned int>();
83 }