3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTModuleAgent.cxx
20 @author Matthias Richter
22 @brief Agent helper class for component libraries.
23 @note The class is used in Offline (AliRoot) context
26 // see header file for class documentation
28 // refer to README to build package
30 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32 #include "AliHLTModuleAgent.h"
33 #include "AliHLTOUTHandler.h"
35 /** ROOT macro for the implementation of ROOT specific class methods */
36 ClassImp(AliHLTModuleAgent)
38 AliHLTModuleAgent::AliHLTModuleAgent(const char* id)
41 fpComponentHandler(NULL),
44 // see header file for class documentation
46 // refer to README to build package
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
52 const char* AliHLTModuleAgent::GetQAPlugins() const
54 // default implementation, childs can overload
58 const AliHLTModuleAgent::AliHLTOUTHandlerDesc AliHLTModuleAgent::fgkVoidHandlerDesc;
60 AliHLTModuleAgent::~AliHLTModuleAgent()
62 // see header file for function documentation
66 const char* AliHLTModuleAgent::GetModuleId() const
68 // see header file for function documentation
69 return fModuleId.Data();
72 void AliHLTModuleAgent::PrintStatus(const char* agent)
74 // see header file for function documentation
77 AliHLTModuleAgent* pCurrent=fgAnchor;
78 while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext;
80 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
81 "agent %s available", pCurrent->GetName());
83 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
84 "agent %s not found", agent);
87 AliHLTModuleAgent* pCurrent=fgAnchor;
88 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
89 log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
91 log.Logging(kHLTLogInfo, "AliHLT", "", " none");
94 msg.Form(" %s : %p", pCurrent->GetName(), pCurrent);
95 log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
96 pCurrent=pCurrent->fpNext;
98 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
102 UInt_t AliHLTModuleAgent::GetDetectorMask() const
108 int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
109 AliRawReader* /*rawReader*/,
110 AliRunLoader* /*runloader*/) const
112 // default method, nothing to be done, child classes can overload
116 const char* AliHLTModuleAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
117 AliRunLoader* /*runloader*/) const
119 // default method, nothing to be done, child classes can overload
123 const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
125 // default method, nothing to be done, child classes can overload
129 int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType /*dt*/,
130 AliHLTUInt32_t /*spec*/,
131 AliHLTOUTHandlerDesc& /*desc*/) const
133 // default method, nothing to be done, child classes can overload
137 AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType /*dt*/,
138 AliHLTUInt32_t /*spec*/)
140 // default method, nothing to be done, child classes can overload
144 int AliHLTModuleAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
146 // default method, simply deletes object
147 if (!pInstance) return -EINVAL;
148 HLTWarning("potential memory leak due to missing implementation, agent %s must implement function DeleteOutputHandler", GetModuleId());
152 // likely to be moved to AliHLTOUTHandler
153 // AliRawStream* AliHLTModuleAgent::GetRawStream(AliHLTComponentDataType /*dt*/,
154 // AliHLTUInt32_t /*spec*/,
155 // const AliHLTOUT* /*pData*/) const
157 // // default method, nothing to be done, child classes can overload
161 int AliHLTModuleAgent::ActivateComponentHandler(AliHLTComponentHandler* pHandler)
163 // see header file for function documentation
165 if (pHandler==NULL) {
166 if (fpComponentHandler!=NULL) {
167 // reset and think about deregistration
168 fpComponentHandler=NULL;
169 HLTWarning("deregistration of components not yet implemented");
173 if (fpComponentHandler!=NULL) {
174 if (pHandler!=fpComponentHandler) {
175 HLTError("only one component handler can be activated per agent");
180 if ((iResult=RegisterComponents(pHandler))>=0) {
181 fpComponentHandler=pHandler;
186 int AliHLTModuleAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const
188 // default method, nothing to be done, child classes can overload
192 AliHLTModulePreprocessor* AliHLTModuleAgent::GetPreprocessor()
194 // default method, nothing to be done, child classes can overload
198 AliHLTModuleAgent* AliHLTModuleAgent::fgAnchor=NULL;
199 AliHLTModuleAgent* AliHLTModuleAgent::fgCurrent=NULL;
200 int AliHLTModuleAgent::fgCount=0;
202 AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
204 // see header file for function documentation
209 AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
211 // see header file for function documentation
212 if (fgCurrent!=NULL) fgCurrent=fgCurrent->fpNext;
216 string AliHLTModuleAgent::GetAgentIds()
218 // see header file for function documentation
221 for (AliHLTModuleAgent* pCurrent=fgAnchor;
223 pCurrent=pCurrent->fpNext) {
224 if (ids.size()>0) ids+=" ";
225 ids+=pCurrent->GetModuleId();
231 int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
233 // see header file for function documentation
235 if (!pAgent) return -EINVAL;
236 // The following check is for extra protection. In some strange cases the agent might
237 // try to register itself more than once. So we need to check for that and prevent it.
238 // Otherwise we create a cycle in our linked list and go into an infinite loop.
239 AliHLTModuleAgent* current=fgAnchor;
240 while (current!=NULL) {
241 if (current == pAgent) return 0;
242 current = current->fpNext;
244 if (fgAnchor==NULL) {
247 pAgent->fpNext=fgAnchor;
250 // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
255 int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
257 // see header file for function documentation
259 if (!pAgent) return -EINVAL;
261 AliHLTModuleAgent* prev=NULL;
262 AliHLTModuleAgent* handler=fgAnchor;
263 while (handler!=NULL && handler!=pAgent) {
265 handler=handler->fpNext;
269 fgAnchor=handler->fpNext;
271 prev->fpNext=handler->fpNext;
273 //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);