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