otsdaq  v2_05_02_indev
DataProducerBase.cc
1 #include "otsdaq/DataManager/DataProducerBase.h"
2 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
3 #include "otsdaq/DataManager/DataManager.h"
4 #include "otsdaq/DataManager/DataManagerSingleton.h"
5 
6 #include <iostream>
7 #include <memory>
8 using namespace ots;
9 
10 #undef __MF_SUBJECT__
11 #define __MF_SUBJECT__ "Producer"
12 #define mfSubject_ (std::string("ProducerBase:") + DataProcessor::processorUID_)
13 
14 //==============================================================================
15 DataProducerBase::DataProducerBase(const std::string& supervisorApplicationUID,
16  const std::string& bufferUID,
17  const std::string& processorUID,
18  unsigned int bufferSize)
19  : DataProcessor(supervisorApplicationUID, bufferUID, processorUID), bufferSize_(bufferSize)
20 {
21  __GEN_COUT__ << "Constructor." << __E__;
22  registerToBuffer();
23  __GEN_COUT__ << "Constructed." << __E__;
24 } // end constructor()
25 
26 //==============================================================================
27 DataProducerBase::~DataProducerBase(void) { __GEN_COUT__ << "Destructed." << __E__; } // end destructor()
28 
29 //==============================================================================
30 // mirror DataConsumer::registerToBuffer
31 void DataProducerBase::registerToBuffer(void)
32 {
33  __GEN_COUT__ << "Producer '" << DataProcessor::processorUID_ << "' is registering to DataManager Supervisor Buffer '"
34  << DataProcessor::supervisorApplicationUID_ << ":" << DataProcessor::bufferUID_ << ".'" << std::endl;
35 
36  DataManager* dataManager = (DataManagerSingleton::getInstance(supervisorApplicationUID_));
37 
38  dataManager->registerProducer(bufferUID_, this);
39 
40  {
41  __GEN_SS__;
42  dataManager->dumpStatus(&ss);
43  std::cout << ss.str() << __E__;
44  }
45 
46  __GEN_COUT__ << "Producer '" << DataProcessor::processorUID_ << "' Registered." << __E__;
47 } // end registerToBuffer()
48 //
51 // void DataProducerBase::unregisterFromBuffer(void)
52 //{
53 // __GEN_COUT__ << "Producer '" << DataProcessor::processorUID_ <<
54 // "' is unregistering to DataManager Supervisor Buffer '" <<
55 // DataProcessor::supervisorApplicationUID_ << ":" <<
56 // DataProcessor::bufferUID_ << ".'" << std::endl;
57 //
58 // DataManager* dataManager =
59 // (DataManagerSingleton::getInstance(
60 // supervisorApplicationUID_));
61 //
62 // dataManager->unregisterProducer(
63 // bufferUID_,DataProcessor::processorUID_);
64 //
65 // {
66 // __GEN_SS__;
67 // dataManager->dumpStatus(&ss);
68 // std::cout << ss.str() << __E__;
69 // }
70 //
71 // __GEN_COUT__ << "Producer '" << DataProcessor::processorUID_ <<
72 // "' Unregistered." << __E__;
73 //} //end unregisterFromBuffer()