otsdaq  v2_05_02_indev
TemplateTable_table.cc
1 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq/Macros/TablePluginMacros.h"
3 #include "otsdaq/TablePlugins/TemplateTable.h"
4 
5 #include <iostream>
6 #include <string>
7 
8 using namespace ots;
9 
10 //==============================================================================
11 TemplateTable::TemplateTable(void) : TableBase("TemplateTable")
12 {
14  // WARNING: the field names used in C++ MUST match the Table INFO //
16 }
17 
18 //==============================================================================
19 TemplateTable::~TemplateTable(void) {}
20 
21 //==============================================================================
22 void TemplateTable::init(ConfigurationManager* configManager)
23 {
24  // use isFirstAppInContext to only run once per context, for example to avoid
25  // generating files on local disk multiple times.
26  bool isFirstAppInContext = configManager->isOwnerFirstAppInContext();
27 
28  __COUTV__(isFirstAppInContext);
29  // if(!isFirstAppInContext) return;
30 
31  // do something to validate or refactor table
32  __COUT__ << "*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
33  __COUT__ << configManager->__SELF_NODE__ << std::endl;
34 
35  // __COUT__ << configManager->getNode(this->getTableName()).getValueAsString()
36  // << std::endl;
37 
38  std::string value;
39  std::vector<std::pair<std::string, ConfigurationTree> > children = configManager->__SELF_NODE__.getChildren();
40  for(auto& childPair : children)
41  {
42  // do something for each row in table
43  __COUT__ << childPair.first << std::endl;
44  __COUT__ << childPair.second.getNode(colNames_.colColumnName_) << std::endl;
45  childPair.second.getNode(colNames_.colColumnName_).getValue(value);
46  }
47 }
48 
49 DEFINE_OTS_TABLE(TemplateTable)