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