]>
Commit | Line | Data |
---|---|---|
8356cc1d | 1 | //////////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // Author: Artur Szostak | |
4 | // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com | |
5 | // | |
6 | //////////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | #ifndef dHLT_FRAMEWORK_GLOBAL_HPP | |
9 | #define dHLT_FRAMEWORK_GLOBAL_HPP | |
10 | ||
11 | #include "BasicTypes.hpp" | |
12 | #include "Buffers/List.hpp" | |
13 | #include "DDL/TriggerInputInterface.hpp" | |
14 | #include "DDL/ADCInputInterface.hpp" | |
15 | #include "Clustering/IOInterface.hpp" | |
16 | #include "Tracking/IOInterface.hpp" | |
17 | #include "Decision/IOInterface.hpp" | |
18 | #include "DDL/TrackOutputInterface.hpp" | |
19 | #include "DDL/DecisionOutputInterface.hpp" | |
20 | #include "Framework/ClusterLookupTable.hpp" | |
21 | ||
22 | namespace dHLT | |
23 | { | |
24 | namespace Framework | |
25 | { | |
26 | ||
27 | ||
28 | using namespace dHLT::Buffers; | |
29 | ||
30 | ||
31 | class Global | |
32 | { | |
33 | public: | |
34 | ||
35 | Global() | |
36 | { | |
37 | }; | |
38 | ||
39 | virtual ~Global() | |
40 | { | |
41 | // clusterfinderlist, trackerlist and decisionlist free their memory implicitly. | |
42 | // Note the objects to which these lists point to are not deleted because they | |
43 | // are not owned by this object. | |
44 | }; | |
45 | ||
46 | DDL::TriggerInputCallback* AddTriggerInput(); | |
47 | bool RemoveTriggerInput(DDL::TriggerInputCallback* interface); | |
48 | ||
49 | DDL::ADCInputCallback* AddADCInput(); | |
50 | bool RemoveADCInput(DDL::ADCInputCallback* interface); | |
51 | ||
52 | Clustering::IOCallback* AddClusterFinder(Clustering::IOInterface* interface); | |
53 | Clustering::IOCallback* AddClusterFinder(Clustering::IOInterface* interface, const ROI region); | |
54 | Clustering::IOCallback* AddClusterFinder(Clustering::IOInterface* interface, const ROI* region, const UInt count); | |
55 | bool RemoveClusterFinder(Clustering::IOInterface* interface); | |
56 | ||
57 | Tracking::IOCallback* AddTracker(Tracking::IOInterface* interface); | |
58 | bool RemoveTracker(Tracking::IOInterface* interface); | |
59 | ||
60 | Decision::IOCallback* AddDecision(Decision::IOInterface* interface); | |
61 | bool RemoveDecision(Decision::IOInterface* interface); | |
62 | ||
63 | DDL::TrackOutputCallback* AddTrackOutput(DDL::TrackOutputInterface* interface); | |
64 | bool RemoveTrackOutput(DDL::TrackOutputInterface* interface); | |
65 | ||
66 | DDL::DecisionOutputCallback* AddDecisionOutput(DDL::DecisionOutputInterface* interface); | |
67 | bool RemoveDecisionOutput(DDL::DecisionOutputInterface* interface); | |
68 | ||
69 | ||
70 | #ifdef DEBUG | |
71 | void Dump(); | |
72 | ||
73 | public: | |
74 | #else // DEBUG | |
75 | private: | |
76 | #endif // DEBUG | |
77 | ||
78 | class FrameworkCallback | |
79 | { | |
80 | public: | |
81 | FrameworkCallback() | |
82 | { | |
83 | framework = NULL; | |
84 | }; | |
85 | ||
86 | friend std::ostream& operator << (std::ostream& os, const FrameworkCallback& fc) | |
87 | { | |
88 | os << (void*) fc.framework; | |
89 | return os; | |
90 | }; | |
91 | ||
92 | Global* framework; | |
93 | }; | |
94 | ||
95 | class TriggerInput : public DDL::TriggerInputCallback, public FrameworkCallback | |
96 | { | |
97 | public: | |
98 | virtual TriggerRecord* AllocateTriggerBlock(const UInt size); | |
99 | virtual void ReturnTriggers(const EventID event, TriggerRecord* triggers, const UInt count); | |
100 | virtual void EndOfTriggers(const EventID event); | |
101 | }; | |
102 | ||
103 | class ADCInput : public DDL::ADCInputCallback, public FrameworkCallback | |
104 | { | |
105 | public: | |
106 | virtual ADCStream* AllocateADCStream(const UInt size); | |
107 | virtual void ReturnADCStream(const EventID event, ADCStream* adcstream); | |
108 | virtual void EndOfADCStreams(const EventID event); | |
109 | }; | |
110 | ||
111 | class ClusterFinder : public Clustering::IOCallback, public FrameworkCallback | |
112 | { | |
113 | public: | |
114 | virtual ClusterPoint* AllocateClusterBlock(const UInt size); | |
115 | virtual void ReturnClusters(const EventID event, const ROI region, ClusterPoint* clusters, const UInt count); | |
116 | virtual void EndOfClusters(const EventID event); | |
117 | virtual void ReleaseADCStream(const ADCStream* stream); | |
118 | ||
119 | ClusterFinder() : Clustering::IOCallback(), FrameworkCallback() { region = INVALID_ROI; }; | |
120 | ROI region; // The region this cluster finder covers. | |
121 | Clustering::IOInterface* interface; | |
122 | }; | |
123 | ||
124 | class Tracker : public Tracking::IOCallback, public FrameworkCallback | |
125 | { | |
126 | public: | |
127 | virtual void RequestClusters(const EventID event, const ROI region); | |
128 | virtual void EndOfClusterRequests(const EventID event); | |
129 | virtual Track* AllocateTrackBlock(const UInt size); | |
130 | virtual void ReturnTracks(const EventID event, Track* newtracks, const UInt count); | |
131 | virtual void EndOfTracks(const EventID event); | |
132 | virtual void ReleaseTriggers(const TriggerRecord* triggers); | |
133 | virtual void ReleaseClusters(const ClusterPoint* clusters); | |
134 | ||
135 | Tracking::IOInterface* interface; | |
136 | }; | |
137 | ||
138 | class DecisionMaker : public Decision::IOCallback, public FrameworkCallback | |
139 | { | |
140 | public: | |
141 | virtual DecisionRecord* AllocateDecisionBlock(const UInt size); | |
142 | virtual void ReturnDecision(const EventID event, DecisionRecord* decision); | |
143 | virtual void EndOfDecisions(const EventID event); | |
144 | virtual void ReleaseTracks(const Track* tracks); | |
145 | ||
146 | Decision::IOInterface* interface; | |
147 | }; | |
148 | ||
149 | class TrackOutput : public DDL::TrackOutputCallback, public FrameworkCallback | |
150 | { | |
151 | public: | |
152 | virtual void ReleaseTracks(const Track* tracks); | |
153 | ||
154 | DDL::TrackOutputInterface* interface; | |
155 | }; | |
156 | ||
157 | class DecisionOutput : public DDL::DecisionOutputCallback, public FrameworkCallback | |
158 | { | |
159 | public: | |
160 | virtual void ReleaseDecision(const DecisionRecord* decision); | |
161 | ||
162 | DDL::DecisionOutputInterface* interface; | |
163 | }; | |
164 | ||
165 | ||
166 | private: | |
167 | ||
168 | //==================== DDL::TriggerInputCallback ========================= | |
169 | void ReturnTriggers(const TriggerInput* sender, const EventID event, TriggerRecord* triggers, const UInt count); | |
170 | void EndOfTriggers(const TriggerInput* sender, const EventID event); | |
171 | ||
172 | //====================== DDL::ADCInputCallback =========================== | |
173 | void ReturnADCStream(const ADCInput* sender, const EventID event, ADCStream* adcstream); | |
174 | void EndOfADCStreams(const ADCInput* sender, const EventID event); | |
175 | ||
176 | //===================== Clustering::IOCallback =========================== | |
177 | void ReturnClusters(const ClusterFinder* sender, const EventID event, const ROI region, ClusterPoint* clusters, const UInt count); | |
178 | void EndOfClusters(const ClusterFinder* sender, const EventID event); | |
179 | void ReleaseADCStream(const ClusterFinder* sender, const ADCStream* stream); | |
180 | ||
181 | //====================== Tracking::IOCallback ============================ | |
182 | void RequestClusters(const Tracker* sender, const EventID event, const ROI region); | |
183 | void EndOfClusterRequests(const Tracker* sender, const EventID event); | |
184 | void ReturnTracks(const Tracker* sender, const EventID event, Track* newtracks, const UInt count); | |
185 | void EndOfTracks(const Tracker* sender, const EventID event); | |
186 | void ReleaseTriggers(const Tracker* sender, const TriggerRecord* triggers); | |
187 | void ReleaseClusters(const Tracker* sender, const ClusterPoint* clusters); | |
188 | ||
189 | //====================== Decision::IOCallback ============================ | |
190 | void ReturnDecision(const DecisionMaker* sender, const EventID event, DecisionRecord* decision); | |
191 | void EndOfDecisions(const DecisionMaker* sender, const EventID event); | |
192 | void ReleaseTracks(const DecisionMaker* sender, const Track* tracks); | |
193 | ||
194 | //==================== DDL::TrackOutputCallback ========================== | |
195 | void ReleaseTracks(const TrackOutput* sender, const Track* tracks); | |
196 | ||
197 | //=================== DDL::DecisionOutputCallback ======================== | |
198 | void ReleaseDecision(const DecisionOutput* sender, const DecisionRecord* decision); | |
199 | ||
200 | ||
201 | typedef List<TriggerInput> TriggerInputList; | |
202 | typedef List<ADCInput> ADCInputList; | |
203 | typedef List<ClusterFinder> ClusterFinderList; | |
204 | typedef List<Tracker> TrackerList; | |
205 | typedef List<DecisionMaker> DecisionMakerList; | |
206 | typedef List<TrackOutput> TrackOutputList; | |
207 | typedef List<DecisionOutput> DecisionOutputList; | |
208 | ||
209 | TriggerInputList triggerinputlist; // List of trigger record input sources. | |
210 | ADCInputList adcinputlist; // List of ADC stream input sources. | |
211 | ClusterFinderList clusterfinderlist; // List of cluster finders. | |
212 | ||
213 | TrackerList::Iterator currenttracker; // Pointer to the current tracker to receive triggers. | |
214 | TrackerList trackerlist; // List of traker objects. | |
215 | ||
216 | DecisionMakerList decisionmakerlist; // List of decision making objects. | |
217 | ||
218 | TrackOutputList trackoutputlist; // List of track block output sinks. | |
219 | DecisionOutputList decisionoutputlist; // List of decision block output sinks. | |
220 | ||
221 | ClusterLookupTable clustertable; | |
222 | }; | |
223 | ||
224 | ||
225 | } // Framework | |
226 | } // dHLT | |
227 | ||
228 | #endif // dHLT_FRAMEWORK_GLOBAL_HPP |