tdaq-develop-2025-02-12
Configurable.cc
1 #include "otsdaq/Configurable/Configurable.h"
2 
3 #include "otsdaq/TablePlugins/XDAQContextTable/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_).isLinkNode() &&
14  theXDAQContextConfigTree_.getNode(theConfigurationPath_).isDisconnected())
15  ? theXDAQContextConfigTree_.getNode(theConfigurationPath_)
16  .getDisconnectedLinkID()
17  : theXDAQContextConfigTree_.getNode(theConfigurationPath_)
18  .getValueAsString())
19 {
20  __CFG_COUT__ << " Configurable class constructed. " << __E__;
21 } // end constructor()
22 
23 //==============================================================================
24 Configurable::~Configurable(void) {}
25 
26 //==============================================================================
27 ConfigurationTree Configurable::getSelfNode() const
28 {
29  // Note: do not save self node as member, because it may change as configuration is
30  // activated
31  return theXDAQContextConfigTree_.getNode(theConfigurationPath_);
32 } // end getSelfNode()
33 
34 //==============================================================================
35 const ConfigurationManager* Configurable::getConfigurationManager() const
36 {
37  return theXDAQContextConfigTree_.getConfigurationManager();
38 }
39 
40 //==============================================================================
41 const std::string& Configurable::getContextUID() const
42 {
43  return theXDAQContextConfigTree_
44  .getForwardNode(theConfigurationPath_, 1 /*steps to xdaq node*/)
46 }
47 
48 //==============================================================================
49 const std::string& Configurable::getApplicationUID() const
50 {
51  return theXDAQContextConfigTree_
52  .getForwardNode(theConfigurationPath_, 3 /*steps to app node*/)
54 }
55 
56 //==============================================================================
57 unsigned int Configurable::getApplicationLID() const
58 {
59  const XDAQContextTable* contextConfig =
60  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
61 
62  return contextConfig
63  ->getApplicationNode(
64  getConfigurationManager(), getContextUID(), getApplicationUID())
65  .getNode(contextConfig->colApplication_.colId_)
66  .getValue<unsigned int>();
67 }
68 
69 //==============================================================================
70 std::string Configurable::getContextAddress() const
71 {
72  const XDAQContextTable* contextConfig =
73  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
74 
75  return contextConfig->getContextNode(getConfigurationManager(), getContextUID())
76  .getNode(contextConfig->colContext_.colAddress_)
77  .getValue<std::string>();
78 }
79 
80 //==============================================================================
81 unsigned int Configurable::getContextPort() const
82 {
83  const XDAQContextTable* contextConfig =
84  getConfigurationManager()->__GET_CONFIG__(XDAQContextTable);
85 
86  return contextConfig->getContextNode(getConfigurationManager(), getContextUID())
87  .getNode(contextConfig->colContext_.colPort_)
88  .getValue<unsigned int>();
89 }
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
navigating between nodes
const std::string & getValueAsString(bool returnLinkTableValue=false) const
const ConfigurationManager * getConfigurationManager(void) const
extracting information from node
void getValue(T &value) const