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