* provided "as is" without express or implied warranty. *
**************************************************************************/
-/** @file AliHLTConfiguration.cxx
- @author Matthias Richter
- @date
- @brief Implementation of HLT configurations.
-*/
+// @file AliHLTConfiguration.cxx
+// @author Matthias Richter
+// @date 2007
+// @brief HLT configuration description for a single component.
+// @note The class is used in Offline (AliRoot) context
// see header file for class documentation
// or
fStringSources(""),
fNofSources(-1),
fListSources(),
- fListSrcElement(),
+ fListSrcElementIdx(-1),
fArguments(""),
fArgc(-1),
fArgv(NULL),
// refer to README to build package
// or
// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
- fListSrcElement=fListSources.begin();
}
AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources,
fStringSources(sources),
fNofSources(-1),
fListSources(),
- fListSrcElement(),
+ fListSrcElementIdx(-1),
fArguments(arguments),
fArgc(-1),
fArgv(NULL),
{
// see header file for function documentation
if (bufsize) fBufferSize=ConvertSizeString(bufsize);
- fListSrcElement=fListSources.begin();
if (id && component) {
if (fgConfigurationHandler) {
fgConfigurationHandler->RegisterConfiguration(this);
} else {
- HLTError("no configuration handler set, abort registration");
+ HLTWarning("no configuration handler set, skip registration");
}
}
}
fStringSources(src.fStringSources),
fNofSources(-1),
fListSources(),
- fListSrcElement(),
+ fListSrcElementIdx(-1),
fArguments(src.fArguments),
fArgc(-1),
fArgv(NULL),
fBufferSize(src.fBufferSize)
{
// see header file for function documentation
- fListSrcElement=fListSources.begin();
}
AliHLTConfiguration& AliHLTConfiguration::operator=(const AliHLTConfiguration& src)
{
// see header file for function documentation
+ if (this==&src) return *this;
+
fID=src.fID;
fComponent=src.fComponent;
fStringSources=src.fStringSources;
// see header file for function documentation
if (fgConfigurationHandler) {
if (fgConfigurationHandler->FindConfiguration(fID.Data())!=NULL) {
+ // remove the configuration from the handler if it exists
+ // but DO NOT remove the clone configuration
fgConfigurationHandler->RemoveConfiguration(this);
}
}
{
// see header file for function documentation
int iResult=0;
- if (fgConfigurationHandler!=NULL) {
+ if (fgConfigurationHandler!=NULL && fgConfigurationHandler!=pHandler) {
fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalInit", HLT_DEFAULT_LOG_KEYWORD, "configuration handler already initialized, overriding object %p with %p", fgConfigurationHandler, pHandler);
}
fgConfigurationHandler=pHandler;
{
// see header file for function documentation
int iResult=0;
- if (pHandler!=NULL && fgConfigurationHandler!=pHandler) {
+ if (fgConfigurationHandler!=NULL && fgConfigurationHandler!=pHandler) {
fgConfigurationHandler->Logging(kHLTLogWarning, "AliHLTConfiguration::GlobalDeinit", HLT_DEFAULT_LOG_KEYWORD, "handler %p is not set, skip ...", pHandler);
return -EBADF;
}
AliHLTConfiguration* pSrc=NULL;
if (id) {
// first check the current element
- if (fListSrcElement!=fListSources.end() && strcmp(id, (*fListSrcElement)->GetName())==0) {
- pSrc=*fListSrcElement;
+ if (fListSrcElementIdx>=0 && fListSrcElementIdx<(int)fListSources.size() &&
+ strcmp(id, (fListSources[fListSrcElementIdx])->GetName())==0) {
+ pSrc=fListSources[fListSrcElementIdx];
} else {
// check the list
return pSrc;
}
-AliHLTConfiguration* AliHLTConfiguration::GetFirstSource()
+AliHLTConfiguration* AliHLTConfiguration::GetFirstSource() const
{
// see header file for function documentation
AliHLTConfiguration* pSrc=NULL;
- if (fNofSources>=0 || ExtractSources()) {
- fListSrcElement=fListSources.begin();
- if (fListSrcElement!=fListSources.end()) pSrc=*fListSrcElement;
+ if (fNofSources>0) {
+ const_cast<AliHLTConfiguration*>(this)->fListSrcElementIdx=-1;
+ pSrc=GetNextSource();
}
return pSrc;
}
-AliHLTConfiguration* AliHLTConfiguration::GetNextSource()
+AliHLTConfiguration* AliHLTConfiguration::GetNextSource() const
{
// see header file for function documentation
AliHLTConfiguration* pSrc=NULL;
if (fNofSources>0) {
- if (fListSrcElement!=fListSources.end() && (++fListSrcElement)!=fListSources.end())
- pSrc=*fListSrcElement;
+ if (fListSrcElementIdx+1<(int)fListSources.size()) {
+ const_cast<AliHLTConfiguration*>(this)->fListSrcElementIdx++;
+ pSrc=fListSources[fListSrcElementIdx];
+ }
}
return pSrc;
}
-int AliHLTConfiguration::SourcesResolved(int bAuto)
+int AliHLTConfiguration::SourcesResolved() const
{
// see header file for function documentation
int iResult=0;
- if (fNofSources>=0 || bAuto && (iResult=ExtractSources())>=0) {
- //HLTDebug("fNofSources=%d", fNofSources);
- //HLTDebug("list size = %d", fListSources.size());
+ if (fNofSources>=0) {
iResult=fNofSources==(int)fListSources.size();
}
return iResult;
while (element!=fListSources.end()) {
if (*element==pConf) {
fListSources.erase(element);
- fListSrcElement=fListSources.end();
+ fListSrcElementIdx=fListSources.size();
// there is no need to re-evaluate until there was a new configuration registered
// -> postpone the invalidation, its done in AliHLTConfigurationHandler::RegisterConfiguration
//InvalidateSources();
return iResult;
}
-void AliHLTConfiguration::PrintStatus()
+void AliHLTConfiguration::PrintStatus() const
{
// see header file for function documentation
HLTLogKeyword("configuration status");
else HLTMessage(" - component string invalid");
if (!fStringSources.IsNull()) HLTMessage(" - sources: \"%s\"", fStringSources.Data());
else HLTMessage(" - no sources");
- if (SourcesResolved(1)<=0)
+ if (SourcesResolved()!=1)
HLTMessage(" there are unresolved sources");
AliHLTConfiguration* pSrc=GetFirstSource();
while (pSrc) {
}
}
-int AliHLTConfiguration::GetArguments(const char*** pArgv)
+void AliHLTConfiguration::Print(const char* option) const
+{
+ // print information
+ if (option && strcmp(option, "status")==0) {
+ PrintStatus();
+ return;
+ }
+ HLTLogKeyword("configuration");
+ HLTMessage("configuration %s: component %s, sources %s, arguments %s",
+ GetName(),
+ GetComponentID(),
+ GetSourceSettings(),
+ GetArgumentSettings()
+ );
+}
+
+int AliHLTConfiguration::GetArguments(const char*** pArgv) const
{
// see header file for function documentation
int iResult=0;
if (pArgv) {
if (fArgc==-1) {
- if ((iResult=ExtractArguments())<0) {
+ if ((iResult=const_cast<AliHLTConfiguration*>(this)->ExtractArguments())<0) {
HLTError("error extracting arguments for configuration %s", GetName());
- fArgc=-EINVAL;
}
} else if (fArgc<0) {
HLTError("previous argument extraction failed");
{
// see header file for function documentation
int iResult=0;
- fNofSources=0;
+ fNofSources=0; // indicates that the function was called, there are either n or 0 sources
+ fListSources.clear();
+ if (!fgConfigurationHandler) {
+ HLTError("global configuration handler not initialized, can not resolve sources");
+ return -EFAULT;
+ }
if (!fStringSources.IsNull()) {
vector<char*> tgtList;
- fListSources.clear();
if ((iResult=InterpreteString(fStringSources.Data(), tgtList))>=0) {
fNofSources=tgtList.size();
vector<char*>::iterator element=tgtList.begin();
while ((element=tgtList.begin())!=tgtList.end()) {
- if (fgConfigurationHandler) {
AliHLTConfiguration* pConf=fgConfigurationHandler->FindConfiguration(*element);
if (pConf) {
//HLTDebug("configuration %s (%p): source \"%s\" (%p) inserted", GetName(), this, pConf->GetName(), pConf);
HLTError("can not find source \"%s\"", (*element));
iResult=-ENOENT;
}
- } else if (iResult>=0) {
- iResult=-EFAULT;
- HLTFatal("global configuration handler not initialized, can not resolve sources");
- }
delete[] (*element);
tgtList.erase(element);
}
- fListSrcElement=fListSources.begin();
}
}
- return iResult;
+ fListSrcElementIdx=-1;
+ return iResult<0?iResult:SourcesResolved();
}
int AliHLTConfiguration::ExtractArguments()
// there are zero arguments
fArgc=0;
}
+ if (iResult<0) fArgc=iResult;
return iResult;
}
-int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList) const
+int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList)
{
// see header file for function documentation
int iResult=0;