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;
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()>=0) {
- 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) {
}
}
+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
{
// 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()
//* ALICE Experiment at CERN, All rights reserved. *
//* See cxx source for full Copyright notice *
-// @file AliHLTConfiguration.h
-// @author Matthias Richter
-// @date
-// @brief HLT configuration description for a single component.
-// @note The class is used in Offline (AliRoot) context
-
-// see below for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+/// @file AliHLTConfiguration.h
+/// @author Matthias Richter
+/// @date
+/// @brief HLT configuration description for a single component.
+/// @note The class is used in Offline (AliRoot) context
#include <vector>
#include <TObject.h>
* The registration mechanism requires the HLT system to be available. The
* global instance of AliHLTSystem is created and retrieved by
* <pre>
- * // setup the HLT system
- * AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
+ * // setup the HLT system
+ * AliHLTSystem* pHLT=AliHLTPluginBase::GetInstance();
* </pre>
*
* A configuration is transformed into a list of AliHLTTask objects by the
* Print status info.
* Short summary on id, component, sources and unresolved sources.
*/
- void PrintStatus();
+ void PrintStatus() const;
+
+ /**
+ * overloaded from TObject
+ * options:
+ * status - print status including the resolved sources
+ */
+ virtual void Print(const char* option="") const;
/**
* Get a certain source.
/**
* Check resolving status.
- * @param bAuto resolve if ==1
- * @return 1 if all sources resolved
+ * @return 1 if all sources resolved, 0 if not yet extracted or not resolved
+ */
+ int SourcesResolved() const;
+
+ /**
+ * extract the source configurations from the sources string
+ * builds up the internal list of source configurations
+ * @result 1 if sources resolved, 0 if not
*/
- int SourcesResolved(int bAuto=0);
+ int ExtractSources();
/**
* Start iteration and get the first source.
* @result pointer to the first configuration descriptor
*/
- AliHLTConfiguration* GetFirstSource();
+ AliHLTConfiguration* GetFirstSource() const;
/**
* Continue iteration and get the next source.
* @result pointer to the next configuration descriptor in the list
*/
- AliHLTConfiguration* GetNextSource();
+ AliHLTConfiguration* GetNextSource() const;
/**
* Invalidate a dependency and mark the configuration to be re-evaluted.
private:
- /* extract the source configurations from the sources string
- */
- int ExtractSources();
-
/* extract arguments from the argument string
*/
int ExtractArguments();
/** the <i>sources</i> string as passed to the constructor */
TString fStringSources; // see above
/** number of resolved sources, -1 indicates re-evaluation */
- int fNofSources; // see above
+ int fNofSources; //! transient
/** list of sources */
- vector<AliHLTConfiguration*> fListSources; // see above
- /** iterator for the above list */
- vector<AliHLTConfiguration*>::iterator fListSrcElement; // see above
+ vector<AliHLTConfiguration*> fListSources; //! transient
+ /** index of the current element in the list of sources */
+ int fListSrcElementIdx; //! transient
/**
* The argument string as passed to the constructor.
*/
TString fArguments; // see above
/** number of arguments */
- int fArgc; // see above
+ int fArgc; //! transient
/** argument array */
- char** fArgv; // see above
+ char** fArgv; //! transient
/** size of the output buffer */
int fBufferSize; // see above
/** the instance of the global configuration handler */
static AliHLTConfigurationHandler* fgConfigurationHandler; //! transient
- ClassDef(AliHLTConfiguration, 0);
+ ClassDef(AliHLTConfiguration, 1);
};
#endif
/**
* Set a temporary keyword
+ * Keywords need to be static const strings, the class handles only
+ * pointers and assumes the strings to be persistent.
* returns the old key value
*/
const char* SetKeyword(const char* keyword)
/* the class AliHLTKeyword is a simple helper class used by the HLTLogKeyword macro
* HLTLogKeyword("a keyword") creates an object of AliHLTKeyword which sets the keyword for the logging class
* the object is destroyed automatically when the current scope is left and so the keyword is set
- * to the original value
+ * to the original value. Please note that all keywords need to be static strings, only pointyers
+ * are handled and the strings required to ber persistent.
*/
class AliHLTKeyword {
public:
{
}
- AliHLTKeyword(AliHLTLogging* parent, const char* keyword)
+ AliHLTKeyword(const AliHLTLogging* parent, const char* keyword)
:
- fpParent(parent),
+ fpParent(const_cast<AliHLTLogging*>(parent)),
fpOriginal(NULL)
{
- if (parent) {
+ // the const cast is on purpose in order to be allowed to use
+ // HLTLogKeyword from const member functions
+ if (fpParent) {
fpOriginal=fpParent->SetKeyword(keyword);
}
}
- AliHLTKeyword(const AliHLTKeyword& kw)
- :
- fpParent(kw.fpParent),
- fpOriginal(kw.fpOriginal)
- {
- }
-
- AliHLTKeyword& operator=(const AliHLTKeyword& kw)
- {
- fpParent=kw.fpParent;
- fpOriginal=kw.fpOriginal;
- return *this;
- }
-
~AliHLTKeyword()
{
if (fpParent) {
}
private:
+ /// copy constructor prohibited
+ AliHLTKeyword(const AliHLTKeyword& kw);
+ /// assignment operator prohibited
+ AliHLTKeyword& operator=(const AliHLTKeyword& kw);
+
AliHLTLogging* fpParent; //! transient
const char* fpOriginal; //! transient
};