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