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 AliHLTModuleAgent::AliHLTOUTHandlerDesc AliHLTModuleAgent::fgkVoidHandlerDesc;
54 AliHLTModuleAgent::~AliHLTModuleAgent()
56 // see header file for function documentation
60 const char* AliHLTModuleAgent::GetModuleId() const
62 // see header file for function documentation
63 return fModuleId.Data();
66 void AliHLTModuleAgent::PrintStatus(const char* agent)
68 // see header file for function documentation
71 AliHLTModuleAgent* pCurrent=fgAnchor;
72 while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext;
74 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
75 "agent %s available", pCurrent->GetName());
77 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
78 "agent %s not found", agent);
81 AliHLTModuleAgent* pCurrent=fgAnchor;
82 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
83 log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
85 log.Logging(kHLTLogInfo, "AliHLT", "", " none");
88 msg.Form(" %s : %p", pCurrent->GetName(), pCurrent);
89 log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
90 pCurrent=pCurrent->fpNext;
92 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
96 int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
97 AliRawReader* /*rawReader*/,
98 AliRunLoader* /*runloader*/) const
100 // default method, nothing to be done, child classes can overload
104 const char* AliHLTModuleAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
105 AliRunLoader* /*runloader*/) const
107 // default method, nothing to be done, child classes can overload
111 const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
113 // default method, nothing to be done, child classes can overload
117 int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType /*dt*/,
118 AliHLTUInt32_t /*spec*/,
119 AliHLTOUTHandlerDesc& /*desc*/) const
121 // default method, nothing to be done, child classes can overload
125 AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType /*dt*/,
126 AliHLTUInt32_t /*spec*/)
128 // default method, nothing to be done, child classes can overload
132 int AliHLTModuleAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
134 // default method, simply deletes object
135 if (pInstance) return -EINVAL;
141 // likely to be moved to AliHLTOUTHandler
142 // AliRawStream* AliHLTModuleAgent::GetRawStream(AliHLTComponentDataType /*dt*/,
143 // AliHLTUInt32_t /*spec*/,
144 // const AliHLTOUT* /*pData*/) const
146 // // default method, nothing to be done, child classes can overload
150 int AliHLTModuleAgent::ActivateComponentHandler(AliHLTComponentHandler* pHandler)
152 // see header file for function documentation
154 if (pHandler==NULL) {
155 if (fpComponentHandler!=NULL) {
156 // reset and think about deregistration
157 fpComponentHandler=NULL;
158 HLTWarning("deregistration of components not yet implemented");
162 if (fpComponentHandler!=NULL) {
163 if (pHandler!=fpComponentHandler) {
164 HLTError("only one component handler can be activated per agent");
169 if ((iResult=RegisterComponents(pHandler))>=0) {
170 fpComponentHandler=pHandler;
175 int AliHLTModuleAgent::RegisterComponents(AliHLTComponentHandler* /*pHandler*/) const
177 // default method, nothing to be done, child classes can overload
181 AliHLTModulePreprocessor* AliHLTModuleAgent::GetPreprocessor()
183 // default method, nothing to be done, child classes can overload
187 AliHLTModuleAgent* AliHLTModuleAgent::fgAnchor=NULL;
188 AliHLTModuleAgent* AliHLTModuleAgent::fgCurrent=NULL;
189 int AliHLTModuleAgent::fgCount=0;
191 AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
193 // see header file for function documentation
198 AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
200 // see header file for function documentation
201 if (fgCurrent!=NULL) fgCurrent=fgCurrent->fpNext;
205 string AliHLTModuleAgent::GetAgentIds()
207 // see header file for function documentation
210 for (AliHLTModuleAgent* pCurrent=fgAnchor;
212 pCurrent=pCurrent->fpNext) {
213 if (ids.size()>0) ids+=" ";
214 ids+=pCurrent->GetModuleId();
220 int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
222 // see header file for function documentation
224 if (!pAgent) return -EINVAL;
225 // The following check is for extra protection. In some strange cases the agent might
226 // try to register itself more than once. So we need to check for that and prevent it.
227 // Otherwise we create a cycle in our linked list and go into an infinite loop.
228 AliHLTModuleAgent* current=fgAnchor;
229 while (current!=NULL) {
230 if (current == pAgent) return 0;
231 current = current->fpNext;
233 if (fgAnchor==NULL) {
236 pAgent->fpNext=fgAnchor;
239 // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
244 int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
246 // see header file for function documentation
248 if (!pAgent) return -EINVAL;
250 AliHLTModuleAgent* prev=NULL;
251 AliHLTModuleAgent* handler=fgAnchor;
252 while (handler!=NULL && handler!=pAgent) {
254 handler=handler->fpNext;
258 fgAnchor=handler->fpNext;
260 prev->fpNext=handler->fpNext;
262 //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);