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 int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
103 AliRawReader* /*rawReader*/,
104 AliRunLoader* /*runloader*/) const
106 // default method, nothing to be done, child classes can overload
110 const char* AliHLTModuleAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
111 AliRunLoader* /*runloader*/) const
113 // default method, nothing to be done, child classes can overload
117 const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
119 // default method, nothing to be done, child classes can overload
123 int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType /*dt*/,
124 AliHLTUInt32_t /*spec*/,
125 AliHLTOUTHandlerDesc& /*desc*/) const
127 // default method, nothing to be done, child classes can overload
131 AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType /*dt*/,
132 AliHLTUInt32_t /*spec*/)
134 // default method, nothing to be done, child classes can overload
138 int AliHLTModuleAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
140 // default method, simply deletes object
141 if (!pInstance) return -EINVAL;
142 HLTWarning("potential memory leak due to missing implementation, agent %s must implement function DeleteOutputHandler", GetModuleId());
146 // likely to be moved to AliHLTOUTHandler
147 // AliRawStream* AliHLTModuleAgent::GetRawStream(AliHLTComponentDataType /*dt*/,
148 // AliHLTUInt32_t /*spec*/,
149 // const AliHLTOUT* /*pData*/) const
151 // // default method, nothing to be done, child classes can overload
155 int AliHLTModuleAgent::ActivateComponentHandler(AliHLTComponentHandler* pHandler)
157 // see header file for function documentation
159 if (pHandler==NULL) {
160 if (fpComponentHandler!=NULL) {
161 // reset and think about deregistration
162 fpComponentHandler=NULL;
163 HLTWarning("deregistration of components not yet implemented");
167 if (fpComponentHandler!=NULL) {
168 if (pHandler!=fpComponentHandler) {
169 HLTError("only one component handler can be activated per agent");
174 if ((iResult=RegisterComponents(pHandler))>=0) {
175 fpComponentHandler=pHandler;
180 int AliHLTModuleAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const
182 // default method, nothing to be done, child classes can overload
186 AliHLTModulePreprocessor* AliHLTModuleAgent::GetPreprocessor()
188 // default method, nothing to be done, child classes can overload
192 AliHLTModuleAgent* AliHLTModuleAgent::fgAnchor=NULL;
193 AliHLTModuleAgent* AliHLTModuleAgent::fgCurrent=NULL;
194 int AliHLTModuleAgent::fgCount=0;
196 AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
198 // see header file for function documentation
203 AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
205 // see header file for function documentation
206 if (fgCurrent!=NULL) fgCurrent=fgCurrent->fpNext;
210 string AliHLTModuleAgent::GetAgentIds()
212 // see header file for function documentation
215 for (AliHLTModuleAgent* pCurrent=fgAnchor;
217 pCurrent=pCurrent->fpNext) {
218 if (ids.size()>0) ids+=" ";
219 ids+=pCurrent->GetModuleId();
225 int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
227 // see header file for function documentation
229 if (!pAgent) return -EINVAL;
230 // The following check is for extra protection. In some strange cases the agent might
231 // try to register itself more than once. So we need to check for that and prevent it.
232 // Otherwise we create a cycle in our linked list and go into an infinite loop.
233 AliHLTModuleAgent* current=fgAnchor;
234 while (current!=NULL) {
235 if (current == pAgent) return 0;
236 current = current->fpNext;
238 if (fgAnchor==NULL) {
241 pAgent->fpNext=fgAnchor;
244 // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
249 int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
251 // see header file for function documentation
253 if (!pAgent) return -EINVAL;
255 AliHLTModuleAgent* prev=NULL;
256 AliHLTModuleAgent* handler=fgAnchor;
257 while (handler!=NULL && handler!=pAgent) {
259 handler=handler->fpNext;
263 fgAnchor=handler->fpNext;
265 prev->fpNext=handler->fpNext;
267 //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);