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