SdAreaSelector.cc
Go to the documentation of this file.
1 #include "SdAreaSelector.h"
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <sdet/Station.h>
6 
7 #include <evt/Event.h>
8 
9 #include <sevt/SEvent.h>
10 #include <sevt/Header.h>
11 
12 #include <utl/Vector.h>
13 #include <utl/ErrorLogger.h>
14 #include <utl/String.h>
15 #include <utl/Reader.h>
16 #include <utl/TabularStream.h>
17 
18 #include <set>
19 
20 using namespace fwk;
21 using namespace evt;
22 using namespace sevt;
23 using namespace utl;
24 using namespace std;
25 
26 using namespace SdAreaSelectorWG;
27 
28 
29 // globals
30 
31 namespace SdAreaSelectorWG {
32 
33  // stl helpers
34  template<typename Iterator>
35  inline
36  Iterator
37  next(Iterator it)
38  {
39  return ++it;
40  }
41 
42 
43  template<typename Container>
44  inline
45  typename Container::iterator
46  erase(Container& c, const typename Container::iterator it)
47  {
48  const typename Container::iterator nextIt = next(it);
49  c.erase(it);
50  return nextIt;
51  }
52 
53 } // namespace SdAreaSelector
54 
55 
56 //-------------------------------------------------------------------------------------------------
57 
60 {
62  Branch topB = cc->GetTopBranch("SdAreaSelector");
63 
64  topB.GetChild("TankSelection").GetData(fTankSelection); // tank selection
65 
66  vector<int>::iterator its=fTankSelection.begin();
67  if (*its != 0)
68  INFO("TankSelection enabled!");
69 
70  return eSuccess;
71 }
72 
73 
75 SdAreaSelector::Run(evt::Event& event)
76 {
77  if (!event.HasSEvent())
78  return eContinueLoop;
79 
80  SEvent& sEvent = event.GetSEvent();
81 
82 
83  vector<int>::iterator its=fTankSelection.begin();
84  if (*its != 0) {
85  int selected = 0;
87  for (SEvent::CandidateStationIterator sCand = sEvent.CandidateStationsBegin(); sCand != sEnde; ++sCand) {
88  int cand = sCand->GetId();
89 
90  for (vector<int>::iterator it=fTankSelection.begin(); it < fTankSelection.end(); ++it) {
91  if (sEvent.HasStation(*it) && cand == *it) {
92  selected++;
93  }
94  }
95  }
96 
97  if (selected !=0) {
98  ostringstream yesid;
99  if (selected == 1)
100  yesid << selected << " requested station takes part in this event.";
101  if (selected > 1)
102  yesid << selected << " requested stations take part in this event.";
103  INFO(yesid);
104  }
105 
106  if (selected == 0) {
107  ostringstream noid;
108  noid << "None of the requested stations takes part in this event";
109  INFO(noid);
110  return eContinueLoop;
111  }
112  }
113  return eSuccess;
114 }
115 
116 
118 SdAreaSelector::Finish()
119 {
120  return eSuccess;
121 }
122 
123 
124 
125 // Configure (x)emacs for this file ...
126 // Local Variables:
127 // mode: c++
128 // End:
bool HasStation(const int stationId) const
Check whether station exists.
Definition: SEvent.cc:81
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
boost::filter_iterator< CandidateStationFilter, StationIterator > CandidateStationIterator
Iterator over candidate stations.
Definition: SEvent.h:68
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
CandidateStationIterator CandidateStationsBegin()
Definition: SEvent.h:72
Iterator next(Iterator it)
Class representing a document branch.
Definition: Branch.h:107
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
Main configuration utility.
Definition: CentralConfig.h:51
CandidateStationIterator CandidateStationsEnd()
Definition: SEvent.h:74
Container::iterator erase(Container &c, const typename Container::iterator it)
bool HasSEvent() const
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)

, generated on Tue Sep 26 2023.