otsdaq  v2_04_01
DQMHistosConsumerConfiguration_configuration.cc
1 #include <iostream>
2 #include "otsdaq-core/ConfigurationPluginDataFormats/DQMHistosConsumerTable.h"
3 #include "otsdaq-coreMacros/TablePluginMacros.h"
4 
5 using namespace ots;
6 
7 //==============================================================================
8 DQMHistosConsumerConfiguration::DQMHistosConsumerConfiguration(void)
9  : TableBase("DQMHistosConsumerConfiguration")
10 {
12  // WARNING: the names and the order MUST match the ones in the enum //
14  // <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
15  // <ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
16  // xsi:noNamespaceSchemaLocation="TableInfo.xsd"> <CONFIGURATION
17  // Name="DQMHistosConsumerConfiguration"> <VIEW
18  // Name="DQM_HISTOS_CONSUMER_CONFIGURATION" Type="File,Database,DatabaseTest">
19  // <COLUMN Name="ProcessorID" StorageName="PROCESSOR_ID"
20  // DataType="VARCHAR2"/> <COLUMN Name="FilePath" StorageName="FILE_PATH"
21  // DataType="VARCHAR2"/> <COLUMN Name="RadixFileName"
22  // StorageName="RADIX_FILE_NAME" DataType="VARCHAR2"/>
23  // <COLUMN Name="SaveFile" StorageName="SAVE_FILE" DataType="VARCHAR2"/>
24  // </VIEW>
25  // </CONFIGURATION>
26  // </ROOT>
27 }
28 
29 //==============================================================================
30 DQMHistosConsumerConfiguration::~DQMHistosConsumerConfiguration(void) {}
31 
32 //==============================================================================
33 void DQMHistosConsumerConfiguration::init(ConfigurationManager* configManager)
34 {
35  std::string processorUID;
36  for(unsigned int row = 0; row < TableBase::activeTableView_->getNumberOfRows(); row++)
37  {
38  TableBase::activeTableView_->getValue(processorUID, row, ProcessorID);
39  processorIDToRowMap_[processorUID] = row;
40  }
41 }
42 
43 //==============================================================================
44 std::vector<std::string> DQMHistosConsumerConfiguration::getProcessorIDList(void) const
45 {
46  std::vector<std::string> list;
47  for(auto& it : processorIDToRowMap_)
48  list.push_back(it.first);
49  return list;
50 }
51 
52 //==============================================================================
53 std::string DQMHistosConsumerConfiguration::getFilePath(std::string processorUID) const
54 {
55  check(processorUID);
56  std::string val;
57  TableBase::activeTableView_->getValue(
58  val, processorIDToRowMap_.find(processorUID)->second, FilePath);
59  return val;
60 }
61 
62 //==============================================================================
63 std::string DQMHistosConsumerConfiguration::getRadixFileName(
64  std::string processorUID) const
65 {
66  check(processorUID);
67  std::string val;
68  TableBase::activeTableView_->getValue(
69  val, processorIDToRowMap_.find(processorUID)->second, RadixFileName);
70  return val;
71 }
72 
73 //==============================================================================
74 bool DQMHistosConsumerConfiguration::getSaveFile(std::string processorUID) const
75 {
76  check(processorUID);
77  bool val;
78  TableBase::activeTableView_->getValue(
79  val, processorIDToRowMap_.find(processorUID)->second, SaveFile);
80  return val;
81 }
82 
83 //==============================================================================
84 void DQMHistosConsumerConfiguration::check(std::string processorUID) const
85 {
86  if(processorIDToRowMap_.find(processorUID) == processorIDToRowMap_.end())
87  {
88  std::cout << __COUT_HDR_FL__ << "Couldn't find processor " << processorUID
89  << " in the UDPDataStreamerConsumerConfiguration!" << std::endl;
90  assert(0);
91  }
92 }
93 
94 DEFINE_OTS_CONFIGURATION(DQMHistosConsumerConfiguration)