]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTModuleAgent.cxx
removing the CTPData from the HLTGlobalTrigger decision because of bug #88431 until...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModuleAgent.cxx
CommitLineData
75dd2de6 1// $Id$
242bb794 2
3/**************************************************************************
9be2600f 4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
242bb794 6 * *
9be2600f 7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
242bb794 9 * *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18
19/** @file AliHLTModuleAgent.cxx
20 @author Matthias Richter
21 @date
22 @brief Agent helper class for component libraries.
23 @note The class is used in Offline (AliRoot) context
24*/
25
13398559 26// see header file for class documentation
27// or
28// refer to README to build package
29// or
30// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31
242bb794 32#include "AliHLTModuleAgent.h"
164de2ba 33#include "AliHLTOUTHandler.h"
242bb794 34
35/** ROOT macro for the implementation of ROOT specific class methods */
36ClassImp(AliHLTModuleAgent)
37
626bfcc1 38AliHLTModuleAgent::AliHLTModuleAgent(const char* id)
79c114b5 39 :
f3506ea2 40 fpNext(NULL),
626bfcc1 41 fpComponentHandler(NULL),
42 fModuleId(id)
242bb794 43{
44 // see header file for class documentation
45 // or
46 // refer to README to build package
47 // or
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49 Register(this);
50}
51
80df291c 52const char* AliHLTModuleAgent::GetQAPlugins() const
53{
54 // default implementation, childs can overload
55 return "";
56}
57
c5123824 58const AliHLTModuleAgent::AliHLTOUTHandlerDesc AliHLTModuleAgent::fgkVoidHandlerDesc;
59
242bb794 60AliHLTModuleAgent::~AliHLTModuleAgent()
61{
62 // see header file for function documentation
63 Unregister(this);
64}
65
626bfcc1 66const char* AliHLTModuleAgent::GetModuleId() const
67{
68 // see header file for function documentation
69 return fModuleId.Data();
70}
71
242bb794 72void AliHLTModuleAgent::PrintStatus(const char* agent)
73{
74 // see header file for function documentation
75 AliHLTLogging log;
7617ca1e 76 if (agent) {
13398559 77 AliHLTModuleAgent* pCurrent=fgAnchor;
7617ca1e 78 while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext;
79 if (pCurrent) {
80 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
81 "agent %s available", pCurrent->GetName());
82 } else {
83 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
84 "agent %s not found", agent);
85 }
242bb794 86 } else {
13398559 87 AliHLTModuleAgent* pCurrent=fgAnchor;
7617ca1e 88 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
89 log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
90 if (pCurrent==NULL)
91 log.Logging(kHLTLogInfo, "AliHLT", "", " none");
92 while (pCurrent) {
93 TString msg;
94 msg.Form(" %s : %p", pCurrent->GetName(), pCurrent);
95 log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
96 pCurrent=pCurrent->fpNext;
97 }
98 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
242bb794 99 }
100}
101
04a939f7 102int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
dee38f1b 103 AliRawReader* /*rawReader*/,
04a939f7 104 AliRunLoader* /*runloader*/) const
242bb794 105{
106 // default method, nothing to be done, child classes can overload
242bb794 107 return 0;
108}
109
dee38f1b 110const char* AliHLTModuleAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
111 AliRunLoader* /*runloader*/) const
242bb794 112{
113 // default method, nothing to be done, child classes can overload
242bb794 114 return NULL;
115}
116
117const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
118{
119 // default method, nothing to be done, child classes can overload
120 return NULL;
121}
122
62bb3cd4 123int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType /*dt*/,
124 AliHLTUInt32_t /*spec*/,
626bfcc1 125 AliHLTOUTHandlerDesc& /*desc*/) const
62bb3cd4 126{
127 // default method, nothing to be done, child classes can overload
128 return 0;
129}
130
131AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType /*dt*/,
164de2ba 132 AliHLTUInt32_t /*spec*/)
62bb3cd4 133{
134 // default method, nothing to be done, child classes can overload
135 return NULL;
136}
137
164de2ba 138int AliHLTModuleAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
62bb3cd4 139{
164de2ba 140 // default method, simply deletes object
75dd2de6 141 if (!pInstance) return -EINVAL;
142 HLTWarning("potential memory leak due to missing implementation, agent %s must implement function DeleteOutputHandler", GetModuleId());
143 return -ENOSYS;
62bb3cd4 144}
145
164de2ba 146// likely to be moved to AliHLTOUTHandler
147// AliRawStream* AliHLTModuleAgent::GetRawStream(AliHLTComponentDataType /*dt*/,
148// AliHLTUInt32_t /*spec*/,
149// const AliHLTOUT* /*pData*/) const
150// {
151// // default method, nothing to be done, child classes can overload
152// return NULL;
153// }
154
f3506ea2 155int AliHLTModuleAgent::ActivateComponentHandler(AliHLTComponentHandler* pHandler)
156{
13398559 157 // see header file for function documentation
f3506ea2 158 int iResult=0;
159 if (pHandler==NULL) {
160 if (fpComponentHandler!=NULL) {
161 // reset and think about deregistration
162 fpComponentHandler=NULL;
163 HLTWarning("deregistration of components not yet implemented");
164 }
165 return 0;
166 }
167 if (fpComponentHandler!=NULL) {
168 if (pHandler!=fpComponentHandler) {
169 HLTError("only one component handler can be activated per agent");
170 return -EINVAL;
171 }
172 return 0;
173 }
174 if ((iResult=RegisterComponents(pHandler))>=0) {
175 fpComponentHandler=pHandler;
176 }
177 return iResult;
178}
179
180int AliHLTModuleAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const
242bb794 181{
242bb794 182 // default method, nothing to be done, child classes can overload
183 return 0;
184}
185
12ec5482 186AliHLTModulePreprocessor* AliHLTModuleAgent::GetPreprocessor()
187{
188 // default method, nothing to be done, child classes can overload
189 return NULL;
190}
191
13398559 192AliHLTModuleAgent* AliHLTModuleAgent::fgAnchor=NULL;
193AliHLTModuleAgent* AliHLTModuleAgent::fgCurrent=NULL;
194int AliHLTModuleAgent::fgCount=0;
7617ca1e 195
242bb794 196AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
197{
198 // see header file for function documentation
13398559 199 fgCurrent=fgAnchor;
200 return fgAnchor;
242bb794 201}
202
203AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
204{
205 // see header file for function documentation
13398559 206 if (fgCurrent!=NULL) fgCurrent=fgCurrent->fpNext;
207 return fgCurrent;
242bb794 208}
209
7dbfa7c9 210string AliHLTModuleAgent::GetAgentIds()
211{
212 // see header file for function documentation
213 string ids;
214 ids.clear();
215 for (AliHLTModuleAgent* pCurrent=fgAnchor;
216 pCurrent;
217 pCurrent=pCurrent->fpNext) {
218 if (ids.size()>0) ids+=" ";
219 ids+=pCurrent->GetModuleId();
220 }
221
222 return ids;
223}
224
242bb794 225int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
226{
227 // see header file for function documentation
228 AliHLTLogging log;
229 if (!pAgent) return -EINVAL;
555bbe8c 230 // The following check is for extra protection. In some strange cases the agent might
231 // try to register itself more than once. So we need to check for that and prevent it.
232 // Otherwise we create a cycle in our linked list and go into an infinite loop.
233 AliHLTModuleAgent* current=fgAnchor;
234 while (current!=NULL) {
235 if (current == pAgent) return 0;
236 current = current->fpNext;
237 }
13398559 238 if (fgAnchor==NULL) {
239 fgAnchor=pAgent;
7617ca1e 240 } else {
13398559 241 pAgent->fpNext=fgAnchor;
242 fgAnchor=pAgent;
242bb794 243 }
7617ca1e 244 // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
13398559 245 fgCount++;
7617ca1e 246 return 0;
242bb794 247}
248
249int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
250{
251 // see header file for function documentation
252 AliHLTLogging log;
253 if (!pAgent) return -EINVAL;
13398559 254 fgCurrent=NULL;
7617ca1e 255 AliHLTModuleAgent* prev=NULL;
13398559 256 AliHLTModuleAgent* handler=fgAnchor;
7617ca1e 257 while (handler!=NULL && handler!=pAgent) {
258 prev=handler;
259 handler=handler->fpNext;
260 }
261 if (handler) {
262 if (prev==NULL) {
13398559 263 fgAnchor=handler->fpNext;
7617ca1e 264 } else {
265 prev->fpNext=handler->fpNext;
266 }
80e562fa 267 //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);
13398559 268 fgCount--;
242bb794 269 }
270 return 0;
271}