]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTModuleAgent.cxx
- added libAliHLTRCU to default libraries
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModuleAgent.cxx
CommitLineData
242bb794 1// @(#) $Id$
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
242bb794 52AliHLTModuleAgent::~AliHLTModuleAgent()
53{
54 // see header file for function documentation
55 Unregister(this);
56}
57
626bfcc1 58const char* AliHLTModuleAgent::GetModuleId() const
59{
60 // see header file for function documentation
61 return fModuleId.Data();
62}
63
242bb794 64void AliHLTModuleAgent::PrintStatus(const char* agent)
65{
66 // see header file for function documentation
67 AliHLTLogging log;
7617ca1e 68 if (agent) {
13398559 69 AliHLTModuleAgent* pCurrent=fgAnchor;
7617ca1e 70 while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext;
71 if (pCurrent) {
72 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
73 "agent %s available", pCurrent->GetName());
74 } else {
75 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
76 "agent %s not found", agent);
77 }
242bb794 78 } else {
13398559 79 AliHLTModuleAgent* pCurrent=fgAnchor;
7617ca1e 80 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
81 log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
82 if (pCurrent==NULL)
83 log.Logging(kHLTLogInfo, "AliHLT", "", " none");
84 while (pCurrent) {
85 TString msg;
86 msg.Form(" %s : %p", pCurrent->GetName(), pCurrent);
87 log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
88 pCurrent=pCurrent->fpNext;
89 }
90 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
242bb794 91 }
92}
93
04a939f7 94int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
dee38f1b 95 AliRawReader* /*rawReader*/,
04a939f7 96 AliRunLoader* /*runloader*/) const
242bb794 97{
98 // default method, nothing to be done, child classes can overload
242bb794 99 return 0;
100}
101
dee38f1b 102const char* AliHLTModuleAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
103 AliRunLoader* /*runloader*/) const
242bb794 104{
105 // default method, nothing to be done, child classes can overload
242bb794 106 return NULL;
107}
108
109const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
110{
111 // default method, nothing to be done, child classes can overload
112 return NULL;
113}
114
62bb3cd4 115int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType /*dt*/,
116 AliHLTUInt32_t /*spec*/,
626bfcc1 117 AliHLTOUTHandlerDesc& /*desc*/) const
62bb3cd4 118{
119 // default method, nothing to be done, child classes can overload
120 return 0;
121}
122
123AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType /*dt*/,
164de2ba 124 AliHLTUInt32_t /*spec*/)
62bb3cd4 125{
126 // default method, nothing to be done, child classes can overload
127 return NULL;
128}
129
164de2ba 130int AliHLTModuleAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
62bb3cd4 131{
164de2ba 132 // default method, simply deletes object
133 if (pInstance) return -EINVAL;
134 delete pInstance;
135 return 0;
62bb3cd4 136}
137
164de2ba 138
139// likely to be moved to AliHLTOUTHandler
140// AliRawStream* AliHLTModuleAgent::GetRawStream(AliHLTComponentDataType /*dt*/,
141// AliHLTUInt32_t /*spec*/,
142// const AliHLTOUT* /*pData*/) const
143// {
144// // default method, nothing to be done, child classes can overload
145// return NULL;
146// }
147
f3506ea2 148int AliHLTModuleAgent::ActivateComponentHandler(AliHLTComponentHandler* pHandler)
149{
13398559 150 // see header file for function documentation
f3506ea2 151 int iResult=0;
152 if (pHandler==NULL) {
153 if (fpComponentHandler!=NULL) {
154 // reset and think about deregistration
155 fpComponentHandler=NULL;
156 HLTWarning("deregistration of components not yet implemented");
157 }
158 return 0;
159 }
160 if (fpComponentHandler!=NULL) {
161 if (pHandler!=fpComponentHandler) {
162 HLTError("only one component handler can be activated per agent");
163 return -EINVAL;
164 }
165 return 0;
166 }
167 if ((iResult=RegisterComponents(pHandler))>=0) {
168 fpComponentHandler=pHandler;
169 }
170 return iResult;
171}
172
173int AliHLTModuleAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const
242bb794 174{
242bb794 175 // default method, nothing to be done, child classes can overload
176 return 0;
177}
178
12ec5482 179AliHLTModulePreprocessor* AliHLTModuleAgent::GetPreprocessor()
180{
181 // default method, nothing to be done, child classes can overload
182 return NULL;
183}
184
13398559 185AliHLTModuleAgent* AliHLTModuleAgent::fgAnchor=NULL;
186AliHLTModuleAgent* AliHLTModuleAgent::fgCurrent=NULL;
187int AliHLTModuleAgent::fgCount=0;
7617ca1e 188
242bb794 189AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
190{
191 // see header file for function documentation
13398559 192 fgCurrent=fgAnchor;
193 return fgAnchor;
242bb794 194}
195
196AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
197{
198 // see header file for function documentation
13398559 199 if (fgCurrent!=NULL) fgCurrent=fgCurrent->fpNext;
200 return fgCurrent;
242bb794 201}
202
203int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
204{
205 // see header file for function documentation
206 AliHLTLogging log;
207 if (!pAgent) return -EINVAL;
13398559 208 if (fgAnchor==NULL) {
209 fgAnchor=pAgent;
7617ca1e 210 } else {
13398559 211 pAgent->fpNext=fgAnchor;
212 fgAnchor=pAgent;
242bb794 213 }
7617ca1e 214 // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
13398559 215 fgCount++;
7617ca1e 216 return 0;
242bb794 217}
218
219int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
220{
221 // see header file for function documentation
222 AliHLTLogging log;
223 if (!pAgent) return -EINVAL;
13398559 224 fgCurrent=NULL;
7617ca1e 225 AliHLTModuleAgent* prev=NULL;
13398559 226 AliHLTModuleAgent* handler=fgAnchor;
7617ca1e 227 while (handler!=NULL && handler!=pAgent) {
228 prev=handler;
229 handler=handler->fpNext;
230 }
231 if (handler) {
232 if (prev==NULL) {
13398559 233 fgAnchor=handler->fpNext;
7617ca1e 234 } else {
235 prev->fpNext=handler->fpNext;
236 }
80e562fa 237 //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);
13398559 238 fgCount--;
242bb794 239 }
240 return 0;
241}