- support for event by event reconstruction added to AliHLTSystem
[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 :
33 fpNext(NULL)
242bb794 34{
35 // see header file for class documentation
36 // or
37 // refer to README to build package
38 // or
39 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
40 Register(this);
41}
42
242bb794 43AliHLTModuleAgent::~AliHLTModuleAgent()
44{
45 // see header file for function documentation
46 Unregister(this);
47}
48
49void AliHLTModuleAgent::PrintStatus(const char* agent)
50{
51 // see header file for function documentation
52 AliHLTLogging log;
7617ca1e 53 if (agent) {
54 AliHLTModuleAgent* pCurrent=fAnchor;
55 while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext;
56 if (pCurrent) {
57 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
58 "agent %s available", pCurrent->GetName());
59 } else {
60 log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents",
61 "agent %s not found", agent);
62 }
242bb794 63 } else {
7617ca1e 64 AliHLTModuleAgent* pCurrent=fAnchor;
65 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
66 log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
67 if (pCurrent==NULL)
68 log.Logging(kHLTLogInfo, "AliHLT", "", " none");
69 while (pCurrent) {
70 TString msg;
71 msg.Form(" %s : %p", pCurrent->GetName(), pCurrent);
72 log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
73 pCurrent=pCurrent->fpNext;
74 }
75 log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
242bb794 76 }
77}
78
04a939f7 79int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* /*handler*/,
dee38f1b 80 AliRawReader* /*rawReader*/,
04a939f7 81 AliRunLoader* /*runloader*/) const
242bb794 82{
83 // default method, nothing to be done, child classes can overload
242bb794 84 return 0;
85}
86
dee38f1b 87const char* AliHLTModuleAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
88 AliRunLoader* /*runloader*/) const
242bb794 89{
90 // default method, nothing to be done, child classes can overload
242bb794 91 return NULL;
92}
93
94const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
95{
96 // default method, nothing to be done, child classes can overload
97 return NULL;
98}
99
dee38f1b 100int AliHLTModuleAgent::RegisterComponents(AliRawReader* /*rawReader*/,
101 AliRunLoader* /*runloader*/) const
242bb794 102{
242bb794 103 // default method, nothing to be done, child classes can overload
104 return 0;
105}
106
7617ca1e 107AliHLTModuleAgent* AliHLTModuleAgent::fAnchor=NULL;
108AliHLTModuleAgent* AliHLTModuleAgent::fCurrent=NULL;
109int AliHLTModuleAgent::fCount=0;
110
242bb794 111AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
112{
113 // see header file for function documentation
7617ca1e 114 fCurrent=fAnchor;
115 return fAnchor;
242bb794 116}
117
118AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
119{
120 // see header file for function documentation
7617ca1e 121 if (fCurrent!=NULL) fCurrent=fCurrent->fpNext;
122 return fCurrent;
242bb794 123}
124
125int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
126{
127 // see header file for function documentation
128 AliHLTLogging log;
129 if (!pAgent) return -EINVAL;
7617ca1e 130 if (fAnchor==NULL) {
131 fAnchor=pAgent;
132 } else {
133 pAgent->fpNext=fAnchor;
134 fAnchor=pAgent;
242bb794 135 }
7617ca1e 136 // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
137 fCount++;
138 return 0;
242bb794 139}
140
141int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
142{
143 // see header file for function documentation
144 AliHLTLogging log;
145 if (!pAgent) return -EINVAL;
7617ca1e 146 fCurrent=NULL;
147 AliHLTModuleAgent* prev=NULL;
148 AliHLTModuleAgent* handler=fAnchor;
149 while (handler!=NULL && handler!=pAgent) {
150 prev=handler;
151 handler=handler->fpNext;
152 }
153 if (handler) {
154 if (prev==NULL) {
155 fAnchor=handler->fpNext;
156 } else {
157 prev->fpNext=handler->fpNext;
158 }
80e562fa 159 //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);
7617ca1e 160 fCount--;
242bb794 161 }
162 return 0;
163}