]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTModuleAgent.cxx
- AliHLTComponent: bugfix in buffer handling; overwrite check added to
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTModuleAgent.cxx
1 // @(#) $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
7  *          for The ALICE Off-line Project.                               *
8  *                                                                        *
9  * Permission to use, copy, modify and distribute this software and its   *
10  * documentation strictly for non-commercial purposes is hereby granted   *
11  * without fee, provided that the above copyright notice appears in all   *
12  * copies and that both the copyright notice and this permission notice   *
13  * appear in the supporting documentation. The authors make no claims     *
14  * about the suitability of this software for any purpose. It is          *
15  * provided "as is" without express or implied warranty.                  *
16  **************************************************************************/
17
18 /** @file   AliHLTModuleAgent.cxx
19     @author Matthias Richter
20     @date   
21     @brief  Agent helper class for component libraries.
22     @note   The class is used in Offline (AliRoot) context
23 */
24
25 #include "AliHLTModuleAgent.h"
26
27 /** ROOT macro for the implementation of ROOT specific class methods */
28 ClassImp(AliHLTModuleAgent)
29
30 AliHLTModuleAgent::AliHLTModuleAgent()
31 {
32   // see header file for class documentation
33   // or
34   // refer to README to build package
35   // or
36   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
37   Register(this);
38 }
39
40 AliHLTModuleAgent::AliHLTModuleAgent(const AliHLTModuleAgent&)
41   :
42   TObject(),
43   AliHLTLogging()
44 {
45   // see header file for function documentation
46 }
47
48 AliHLTModuleAgent& AliHLTModuleAgent::operator=(const AliHLTModuleAgent&)
49 {
50   // see header file for function documentation
51   return *this;
52 }
53
54 TList AliHLTModuleAgent::fgAgentList;
55 TObjLink* AliHLTModuleAgent::fgCurrentLnk=NULL;
56
57 AliHLTModuleAgent::~AliHLTModuleAgent()
58 {
59   // see header file for function documentation
60   Unregister(this);
61 }
62
63 void AliHLTModuleAgent::PrintStatus(const char* agent)
64 {
65   // see header file for function documentation
66   AliHLTLogging log;
67   if (agent) {
68     TObject* pAgent=fgAgentList.FindObject(agent);
69     if (pAgent) {
70       log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", 
71                   "agent %s available", pAgent->GetName());
72     } else {
73       log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", 
74                   "agent %s not found", agent);
75     }
76   } else {
77     TObjLink* lnk=fgAgentList.FirstLink();
78     log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
79     log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents");
80     if (lnk==NULL) 
81       log.Logging(kHLTLogInfo, "AliHLT", "", "   none");
82     while (lnk) {
83       TString msg;
84       msg.Form("   %s : %p", ((AliHLTModuleAgent*)lnk->GetObject())->GetName(), lnk->GetObject());
85       log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data());
86       lnk=lnk->Next();
87     }
88     log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------");
89   }
90 }
91
92 int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* handler,
93                                             AliRunLoader* runloader) const
94 {
95   // default method, nothing to be done, child classes can overload
96   if (handler==NULL && runloader==NULL) {
97     // get rid of 'unused parameter' warning
98   }
99   return 0;
100 }
101
102 const char* AliHLTModuleAgent::GetTopConfigurations(AliRunLoader* runloader) const
103 {
104   // default method, nothing to be done, child classes can overload
105   if (runloader==NULL) {
106     // get rid of 'unused parameter' warning
107   }
108   return NULL;
109 }
110
111 const char* AliHLTModuleAgent::GetRequiredComponentLibraries() const
112 {
113   // default method, nothing to be done, child classes can overload
114   return NULL;
115 }
116
117 int AliHLTModuleAgent::RegisterComponents(AliRunLoader* runloader) const
118 {
119   if (runloader==NULL) {
120     // get rid of 'unused parameter' warning
121   }
122   // default method, nothing to be done, child classes can overload
123   return 0;
124 }
125
126 AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent()
127 {
128   // see header file for function documentation
129   fgCurrentLnk=fgAgentList.FirstLink();
130   if (fgCurrentLnk==NULL) return NULL;
131   return (AliHLTModuleAgent*)fgCurrentLnk->GetObject();
132 }
133
134 AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent()
135 {
136   // see header file for function documentation
137   if (fgCurrentLnk==NULL) return NULL;
138   fgCurrentLnk=fgCurrentLnk->Next();
139   if (fgCurrentLnk==NULL) return NULL;
140   return (AliHLTModuleAgent*)fgCurrentLnk->GetObject();
141 }
142
143 int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent)
144 {
145   // see header file for function documentation
146   AliHLTLogging log;
147   if (!pAgent) return -EINVAL;
148   if (fgAgentList.FindObject(pAgent)==NULL) {
149     log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent);
150     fgAgentList.Add(pAgent);
151   }
152   return 0;
153 }
154
155 int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent)
156 {
157   // see header file for function documentation
158   AliHLTLogging log;
159   if (!pAgent) return -EINVAL;
160   if (fgAgentList.FindObject(pAgent)!=NULL) {
161     log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent);
162     fgAgentList.Remove(pAgent);
163   } else {
164   }
165   return 0;
166 }