otsdaq  v2_04_01
UDPDataListenerProducerConfiguration_configuration.cc
1 #include <iostream>
2 #include "otsdaq-core/ConfigurationPluginDataFormats/UDPDataListenerProducerTable.h"
3 #include "otsdaq-coreMacros/TablePluginMacros.h"
4 
5 using namespace ots;
6 
7 //==============================================================================
8 UDPDataListenerProducerConfiguration::UDPDataListenerProducerConfiguration(void)
9  : TableBase("UDPDataListenerProducerConfiguration")
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="UDPDataListenerProducerConfiguration"> <VIEW
18  // Name="UDP_DATA_LISTENER_PRODUCER_CONFIGURATION" Type="File,Database,DatabaseTest">
19  // <COLUMN Name="ProcessorID" StorageName="PROCESSOR_ID" DataType="VARCHAR2"/>
20  // <COLUMN Name="BufferSize" StorageName="BUFFER_SIZE" DataType="NUMBER" />
21  // <COLUMN Name="IPAddress" StorageName="IP_ADDRESS" DataType="VARCHAR2"/>
22  // <COLUMN Name="Port" StorageName="PORT" DataType="NUMBER" />
23  // </VIEW>
24  // </CONFIGURATION>
25  // </ROOT>
26 }
27 
28 //==============================================================================
29 UDPDataListenerProducerConfiguration::~UDPDataListenerProducerConfiguration(void) {}
30 
31 //==============================================================================
32 void UDPDataListenerProducerConfiguration::init(ConfigurationManager* configManager)
33 {
34  std::string processorUID;
35  for(unsigned int row = 0; row < TableBase::activeTableView_->getNumberOfRows(); row++)
36  {
37  TableBase::activeTableView_->getValue(processorUID, row, ProcessorID);
38  processorIDToRowMap_[processorUID] = row;
39  }
40 }
41 
42 //==============================================================================
43 unsigned int UDPDataListenerProducerConfiguration::getBufferSize(
44  std::string processorUID) const
45 {
46  check(processorUID);
47  unsigned int val;
48  TableBase::activeTableView_->getValue(
49  val, processorIDToRowMap_.find(processorUID)->second, BufferSize);
50  return val;
51 }
52 
53 //==============================================================================
54 std::string UDPDataListenerProducerConfiguration::getIPAddress(
55  std::string processorUID) const
56 {
57  check(processorUID);
58  std::string val;
59  TableBase::activeTableView_->getValue(
60  val, processorIDToRowMap_.find(processorUID)->second, IPAddress);
61  return val;
62 }
63 
64 //==============================================================================
65 unsigned int UDPDataListenerProducerConfiguration::getPort(std::string processorUID) const
66 {
67  check(processorUID);
68  unsigned int val;
69  TableBase::activeTableView_->getValue(
70  val, processorIDToRowMap_.find(processorUID)->second, Port);
71  return val;
72 }
73 
74 //==============================================================================
75 void UDPDataListenerProducerConfiguration::check(std::string processorUID) const
76 {
77  if(processorIDToRowMap_.find(processorUID) == processorIDToRowMap_.end())
78  {
79  std::cout << __COUT_HDR_FL__ << "Couldn't find processor " << processorUID
80  << " in the UDPDataStreamerConsumerConfiguration!" << std::endl;
81  assert(0);
82  }
83 }
84 
85 DEFINE_OTS_CONFIGURATION(UDPDataListenerProducerConfiguration)