otsdaq  v2_05_02_indev
SupervisorDescriptorInfoBase.cc
1 #include "otsdaq/SupervisorInfo/SupervisorDescriptorInfoBase.h"
2 
3 #include <xdaq/ContextDescriptor.h>
4 #include "otsdaq/MessageFacility/MessageFacility.h"
5 
6 #include <cassert>
7 
8 using namespace ots;
9 
10 //==============================================================================
11 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(void) {}
12 
13 //==============================================================================
14 SupervisorDescriptorInfoBase::SupervisorDescriptorInfoBase(xdaq::ApplicationContext* applicationContext) { init(applicationContext); }
15 
16 //==============================================================================
17 SupervisorDescriptorInfoBase::~SupervisorDescriptorInfoBase() {}
18 
19 //==============================================================================
20 void SupervisorDescriptorInfoBase::destroy() { allSupervisors_.clear(); }
21 
22 //==============================================================================
23 void SupervisorDescriptorInfoBase::init(xdaq::ApplicationContext* applicationContext)
24 {
25  if(applicationContext->getDefaultZone()->getApplicationGroup("daq") == 0)
26  {
27  __SS__ << "Could not find xdaq application group \"daq\" (Must not be present in "
28  "the xdaq context configuration)"
29  << __E__;
30  __SS_THROW__;
31  }
32 
33  __COUT__ << "Init" << __E__;
34 
35  // //There is only one and only Supervisor! (Or Config Wizard!!)
36  // theSupervisor_ =
37  //*(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::Supervisor").begin());
38  // if(0)//theSupervisor_ == 0)
39  // __COUT__ << "Note: Could not find xdaq application descriptor
40  //\"ots::Supervisor\" (Must not be present in the xdaq context configuration)" <<
41  //__E__;
42  //
43  // theWizard_ =
44  //*(applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors("ots::OtsConfigurationWizardSupervisor").begin());
45  // if(0)//theWizard_ == 0)
46  // __COUT__ << "Note: Could not find xdaq application descriptor
47  //\"ots::OtsConfigurationWizardSupervisor\" (Must not be present in the xdaq context
48  // configuration)" << __E__;
49  //
50  // if(theWizard_ == 0 && theSupervisor_ == 0)
51  // {
52  // __SS__ << "Must have THE ots::Supervisor (or THE
53  // ots::OtsConfigurationWizardSupervisor) as part of the context configuration!" <<
54  //__E__;
55  // __COUT_ERR__ << "\n" << ss.str();
56  // __SS_THROW__;
57  // }
58 
59  std::set<XDAQ_CONST_CALL xdaq::ApplicationDescriptor*> appDescriptors;
60 
61  // get allSupervisors_
62 
63  // allFETypeSupervisors_.clear();
64  allSupervisors_.clear();
65  appDescriptors = applicationContext->getDefaultZone()->getApplicationGroup("daq")->getApplicationDescriptors();
66  for(auto& it : appDescriptors)
67  {
68  auto /*<it,bool*/ retPair =
69  allSupervisors_.emplace(std::pair<xdata::UnsignedIntegerT, XDAQ_CONST_CALL xdaq::ApplicationDescriptor*>(it->getLocalId(), it));
70  if(!retPair.second)
71  {
72  __SS__ << "Error! Duplicate Application IDs are not allowed. ID =" << it->getLocalId() << __E__;
73  __SS_THROW__;
74  }
75  }
76 }
77 
78 //==============================================================================
79 const SupervisorDescriptors& SupervisorDescriptorInfoBase::getAllDescriptors(void) const { return allSupervisors_; }