]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTModuleAgent.cxx
- extended high-level component interface: header buffer before TObjects,
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModuleAgent.cxx
1 // @(#) $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  for The ALICE HLT Project.                            *
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 */
29 ClassImp(AliHLTModuleAgent)
30
31 AliHLTModuleAgent::AliHLTModuleAgent()
32   :
33   fpNext(NULL)
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
43 AliHLTModuleAgent::AliHLTModuleAgent(const AliHLTModuleAgent&)
44   :
45   TObject(),
46   AliHLTLogging(),
47   fpNext(NULL)
48 {
49   // see header file for function documentation
50 }
51
52 AliHLTModuleAgent& AliHLTModuleAgent::operator=(const AliHLTModuleAgent&)
53 {
54   // see header file for function documentation
55   return *this;
56 }
57
58 AliHLTModuleAgent::~AliHLTModuleAgent()
59 {
60   // see header file for function documentation
61   Unregister(this);
62 }
63
64 void AliHLTModuleAgent::PrintStatus(const char* agent)
65 {
66   // see header file for function documentation
67   AliHLTLogging log;
68  if (agent) {
69    AliHLTModuleAgent* pCurrent=fAnchor;
70    while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext;
71    if (pCurrent) {
72      log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", 
73                  "agent %s available", pCurrent->GetName());
74    } else {
75      log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", 
76                  "agent %s not found", agent);
77    }
78   } else {
79    AliHLTModuleAgent* pCurrent=fAnchor;
80    log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
81    log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
82    if (pCurrent==NULL)
83      log.Logging(kHLTLogInfo, "AliHLT", "", "   none");
84    while (pCurrent) {
85      TString msg;
86      msg.Form("   %s : %p", pCurrent->GetName(), pCurrent);
87      log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
88      pCurrent=pCurrent->fpNext;
89    }
90    log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
91   }
92 }
93
94 int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
95                                             AliRunLoader* runloader) const
96 {
97   // default method, nothing to be done, child classes can overload
98   if (handler==NULL && runloader==NULL) {
99     // get rid of 'unused parameter' warning
100   }
101   return 0;
102 }
103
104 const char* AliHLTModuleAgent::GetLocalRecConfigurations(AliRunLoader* runloader) const
105 {
106   // default method, nothing to be done, child classes can overload
107   if (runloader==NULL) {
108     // get rid of 'unused parameter' warning
109   }
110   return NULL;
111 }
112
113 const char* AliHLTModuleAgent::GetEventRecConfigurations(AliRunLoader* runloader) const
114 {
115   // default method, nothing to be done, child classes can overload
116   if (runloader==NULL) {
117     // get rid of 'unused parameter' warning
118   }
119   return NULL;
120 }
121
122 const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
123 {
124   // default method, nothing to be done, child classes can overload
125   return NULL;
126 }
127
128 int AliHLTModuleAgent::RegisterComponents(AliRunLoader* runloader) const
129 {
130   if (runloader==NULL) {
131     // get rid of 'unused parameter' warning
132   }
133   // default method, nothing to be done, child classes can overload
134   return 0;
135 }
136
137 AliHLTModuleAgent* AliHLTModuleAgent::fAnchor=NULL;
138 AliHLTModuleAgent* AliHLTModuleAgent::fCurrent=NULL;
139 int AliHLTModuleAgent::fCount=0;
140
141 AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
142 {
143   // see header file for function documentation
144   fCurrent=fAnchor;
145   return fAnchor;
146 }
147
148 AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
149 {
150   // see header file for function documentation
151   if (fCurrent!=NULL) fCurrent=fCurrent->fpNext;
152   return fCurrent;
153 }
154
155 int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
156 {
157   // see header file for function documentation
158   AliHLTLogging log;
159   if (!pAgent) return -EINVAL;
160   if (fAnchor==NULL) {
161     fAnchor=pAgent;
162   } else {
163     pAgent->fpNext=fAnchor;
164     fAnchor=pAgent;
165   }
166   //  log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
167   fCount++;
168   return 0;     
169 }
170
171 int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
172 {
173   // see header file for function documentation
174   AliHLTLogging log;
175   if (!pAgent) return -EINVAL;
176   fCurrent=NULL;
177   AliHLTModuleAgent* prev=NULL;
178   AliHLTModuleAgent* handler=fAnchor;
179   while (handler!=NULL && handler!=pAgent) {
180     prev=handler;
181     handler=handler->fpNext;
182   }
183   if (handler) {
184     if (prev==NULL) {
185       fAnchor=handler->fpNext;
186     } else {
187       prev->fpNext=handler->fpNext;
188     }
189     //log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);
190     fCount--;
191   }
192   return 0;
193 }