]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTConfigurationHandler.cxx
- HLT simulation writes digit data in addition to raw data
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfigurationHandler.cxx
CommitLineData
7a436c89 1// $Id$
2// splitted from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47
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 AliHLTConfigurationHandler.cxx
20 @author Matthias Richter
21 @date
22 @brief Implementation of HLT tasks.
23*/
24
25// see header file for class documentation
26// or
27// refer to README to build package
28// or
29// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31#if __GNUC__>= 3
32using namespace std;
33#endif
34
35#include <cerrno>
36#include <iostream>
37#include <string>
38#include "AliHLTConfigurationHandler.h"
39#include "AliHLTConfiguration.h"
40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp(AliHLTConfigurationHandler)
43
44AliHLTConfigurationHandler::AliHLTConfigurationHandler()
45 :
46 fgListConfigurations()
47{
48 // see header file for class documentation
49 // or
50 // refer to README to build package
51 // or
52 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
53 SetLocalLoggingLevel(kHLTLogInfo);
54}
55
56AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
57{
58 // see header file for function documentation
59 TObjLink* lnk=NULL;
60 while ((lnk=fgListConfigurations.FirstLink())!=NULL) {
61 AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject();
62 HLTDebug("delete configuration \"%s\"", pConf->GetName());
63 fgListConfigurations.Remove(lnk);
64 delete pConf;
65 }
66}
67
68int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
69{
70 // see header file for function documentation
71 int iResult=0;
72 if (pConf) {
73 if (FindConfiguration(pConf->GetName()) == NULL) {
74 AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
75 fgListConfigurations.Add(pClone);
76 HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
77
78 // mark all configurations with unresolved dependencies for re-evaluation
79 TObjLink* lnk=fgListConfigurations.FirstLink();
80 while (lnk) {
81 AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
82 if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
83 pSrc->InvalidateSources();
84 }
85 lnk=lnk->Next();
86 }
87 } else {
88 iResult=-EEXIST;
89 HLTWarning("configuration \"%s\" already registered", pConf->GetName());
90 }
91 } else {
92 iResult=-EINVAL;
93 }
94 return iResult;
95}
96
97int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
98{
99 // see header file for function documentation
100 int iResult=0;
101 AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
102 if (pConf) {
103 // the configuration will be registered automatically, if this failes the configuration
104 // is missing -> delete it
105 if (FindConfiguration(id)==NULL) {
106 delete pConf;
107 pConf=NULL;
108 iResult=-EEXIST;
109 }
110 } else {
111 HLTError("system error: object allocation failed");
112 iResult=-ENOMEM;
113 }
114 return iResult;
115}
116
117void AliHLTConfigurationHandler::PrintConfigurations()
118{
119 // see header file for function documentation
120 HLTLogKeyword("configuration listing");
121 HLTMessage("registered configurations:");
122 TObjLink *lnk = fgListConfigurations.FirstLink();
123 while (lnk) {
124 TObject *obj = lnk->GetObject();
125 HLTMessage(" %s", obj->GetName());
126 lnk = lnk->Next();
127 }
128}
129
130int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
131{
132 // see header file for function documentation
133 int iResult=0;
134 if (id) {
135 AliHLTConfiguration* pConf=NULL;
136 if ((pConf=FindConfiguration(id))!=NULL) {
137 iResult=RemoveConfiguration(pConf);
138 delete pConf;
139 pConf=NULL;
140 } else {
141 HLTWarning("can not find configuration \"%s\"", id);
142 iResult=-ENOENT;
143 }
144 } else {
145 iResult=-EINVAL;
146 }
147 return iResult;
148}
149
150int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
151{
152 // see header file for function documentation
153 int iResult=0;
154 if (pConf) {
155 // remove the configuration from the list
156 HLTDebug("remove configuration \"%s\"", pConf->GetName());
157 fgListConfigurations.Remove(pConf);
158 // remove cross links in the remaining configurations
159 TObjLink* lnk=fgListConfigurations.FirstLink();
160 while (lnk && iResult>=0) {
161 AliHLTConfiguration* pRem=(AliHLTConfiguration*)lnk->GetObject();
162 if (pRem) {
163 pRem->InvalidateSource(pConf);
164 } else {
165 iResult=-EFAULT;
166 }
167 lnk=lnk->Next();
168 }
169 }
170 return iResult;
171}
172
173AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
174{
175 // see header file for function documentation
176 AliHLTConfiguration* pConf=NULL;
177 if (id) {
178 pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);
179 }
180 return pConf;
181}
182