DDTConnectConfig.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/DAQConfig/DDTConnectConfig.h>
2 #include <DatabaseUtils/DAQConfig/ConfigDataTree.h>
3 #include <DatabaseUtils/DAQConfig/DBColumnParams.h>
4 #include <DatabaseUtils/DAQConfig/DBColumnUtils.h>
5 #include <DatabaseUtils/DAQConfig/NamedConfigUtils.h>
6 #include <NovaDatabase/Table.h>
7 #include <NovaDAQUtilities/EnvVarCache.h>
8 #include <boost/algorithm/string.hpp>
9 
10 namespace NOVADB = nova::database;
11 
12 namespace dbutils {
13 namespace daqconfig {
14 
15 /**
16  * Creates a DDT Connection configuration object from the specified
17  * list of subsystem configuration IDs.
18  *
19  * @param subsystemConfigIdList The list of subsystem
20  * configuration IDs.
21  */
23  DDTConnectConfig(const std::vector<int64_t>& subsystemConfigIdList)
24  {
26  if (subsystemConfigIdList.size() > 0) {
27  _primarySubsystemConfigId = subsystemConfigIdList[0];
28  _hasValidData = _fetchAllData(subsystemConfigIdList);
29  }
30  else {
31  _hasValidData = false;
32  }
33  }
34 
35  /**
36  * Creates a DDT Connection configuration object from the specified
37  * subsystem configuration specification.
38  *
39  * @param nameSpec The named configuration of interest.
40  */
42  {
44  std::vector<int64_t> subsystemConfigIdList;
45  if (NamedConfigUtils::
46  getSubsystemConfigIdAncestry(nameSpec, subsystemConfigIdList)) {
47  _primarySubsystemConfigId = subsystemConfigIdList[0];
48  _hasValidData = _fetchAllData(subsystemConfigIdList);
49  }
50  else {
51  _hasValidData = false;
52  }
53  }
54 
55  /**
56  * Creates a DDT Connection configuration object from the specified
57  * global configuration specification.
58  *
59  * @param nameSpec The named configuration of interest.
60  */
62  {
64  int64_t subsystemConfigId;
68  DDT_SUBSYSTEM_NAME,
70  CONNECT_CONFIG_TYPE,
71  subsystemConfigId);
72 
73  std::vector<int64_t> subsystemConfigIdList;
74  if (status) {
75  IDSpec idSpec(subsystemConfigId, IDSpec::SUBSYSTEM, IDSpec::DAQ);
76  status = NamedConfigUtils::
77  getConfigIdAncestry(idSpec, subsystemConfigIdList);
78  }
79 
80  if (status) {
81  _primarySubsystemConfigId = subsystemConfigIdList[0];
82  _hasValidData = _fetchAllData(subsystemConfigIdList);
83  }
84  else {
85  _hasValidData = false;
86  }
87  }
88 
89  /**
90  * Creates a DDT Connection configuration object from the specified
91  * global configuration ID.
92  *
93  * @param globalConfigId The ID of the global configuration of interest.
94  */
95  DDTConnectConfig::DDTConnectConfig(const int64_t& globalConfigId)
96  {
97  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL, IDSpec::DAQ);
99  std::vector<int64_t> subsystemConfigIdList;
100  if (NamedConfigUtils::
101  getSubsystemConfigIdAncestryFromGlobalId(idSpec,
103  DDT_SUBSYSTEM_NAME,
105  CONNECT_CONFIG_TYPE,
106  subsystemConfigIdList)) {
107  _primarySubsystemConfigId = subsystemConfigIdList[0];
108  _hasValidData = _fetchAllData(subsystemConfigIdList);
109  }
110  else {
111  _hasValidData = false;
112  }
113  }
114 
115  bool DDTConnectConfig::
116  _fetchAllData(const std::vector<int64_t>& subsystemConfigIdList)
117  {
118  std::string table_name =
119  "NovaDatabase/tables/DAQConfig/DDTManagerConnectParameters.xml";
120 
121  ConfigDataSelector cfgSelector;
123 
124  std::vector<std::string> dataColumnsOfInterest;
125  dataColumnsOfInterest.push_back("configPath");
126  dataColumnsOfInterest.push_back("nProcesses");
127  dataColumnsOfInterest.push_back("version");
128  dataColumnsOfInterest.push_back("qualifier");
129 
130  _ddtConfigDataTree.reset
131  (new ConfigDataTree(table_name, subsystemConfigIdList,
132  cfgSelector, dataColumnsOfInterest));
133 
134  return _ddtConfigDataTree->hasValidData();
135  }
136 } // end of namespace daqconfig
137 } // end of namespace dbutils
void addSelectionColumn(std::string columnName)
int status
Definition: fabricate.py:1613
static bool getConfigIdAncestry(const IDSpec &idSpec, std::vector< int64_t > &idList, const std::string &tableFile=DEFAULT_GLOBAL_NAMES_TABLE_FILE)
DDTConnectConfig(const std::vector< int64_t > &subsystemConfigIdList)
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList)
static const std::string HOSTNAME_COLUMN_NAME
static bool getSubsystemConfigIdFromGlobalName(const GlobalNameSpec &globalNameSpec, const std::string &subsystemName, const std::string &subsystemConfigType, int64_t &subsystemConfigId, const std::string &globalNamesTableFile=DEFAULT_GLOBAL_NAMES_TABLE_FILE, const std::string &subsystemNamesTableFile=DEFAULT_SUBSYSTEM_NAMES_TABLE_FILE)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
boost::shared_ptr< ConfigDataTree > _ddtConfigDataTree