+
+int AliHLTComponent::ExtractComponentTableEntry(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size,
+ string& retChainId, string& retCompId, string& retCompArgs,
+ vector<AliHLTUInt32_t>& parents)
+{
+ // see header file for function documentation
+ retChainId.clear();
+ retCompId.clear();
+ retCompArgs.clear();
+ parents.clear();
+ if (!pBuffer || size==0) return 0;
+
+ const AliHLTComponentTableEntry* pEntry=reinterpret_cast<const AliHLTComponentTableEntry*>(pBuffer);
+ if (size<8/* the initial size of the structure*/ ||
+ pEntry==NULL || pEntry->fStructSize<8) return -ENOMSG;
+ const AliHLTUInt32_t* pParents=reinterpret_cast<const AliHLTUInt32_t*>(pEntry->fBuffer);
+ const AliHLTUInt8_t* pEnd=pBuffer+size;
+
+ if (pParents+pEntry->fNofParents>=reinterpret_cast<const AliHLTUInt32_t*>(pEnd)) return -ENODEV;
+ for (unsigned int i=0; i<pEntry->fNofParents; i++, pParents++) {
+ parents.push_back(*pParents);
+ }
+
+ const char* pDescription=reinterpret_cast<const char*>(pParents);
+ if (pDescription+pEntry->fSizeDescription>=reinterpret_cast<const char*>(pEnd) ||
+ *(pDescription+pEntry->fSizeDescription)!=0) {
+ return -EBADF;
+ }
+
+ TString descriptor=reinterpret_cast<const char*>(pDescription);
+ TString chainId;
+ TString compId;
+ TString compArgs;
+ TObjArray* pTokens=descriptor.Tokenize("{");
+ if (pTokens) {
+ int n=0;
+ if (pTokens->GetEntries()>n) {
+ retChainId=((TObjString*)pTokens->At(n++))->GetString();
+ }
+ if (pTokens->GetEntries()>n) {
+ compId=((TObjString*)pTokens->At(n++))->GetString();
+ }
+ delete pTokens;
+ }
+ if (!compId.IsNull() && (pTokens=compId.Tokenize(":"))!=NULL) {
+ int n=0;
+ if (pTokens->GetEntries()>n) {
+ compId=((TObjString*)pTokens->At(n++))->GetString();
+ }
+ if (pTokens->GetEntries()>n) {
+ compArgs=((TObjString*)pTokens->At(n++))->GetString();
+ }
+ delete pTokens;
+ }
+ compId.ReplaceAll("}", "");
+ compArgs.ReplaceAll("}", "");
+
+ retCompId=compId;
+ retCompArgs=compArgs;
+
+ if (retChainId.size()==0) return -ENODATA;
+
+ return 1;
+}
+
+int AliHLTComponent::LoggingVarargs(AliHLTComponentLogSeverity severity,
+ const char* originClass, const char* originFunc,
+ const char* file, int line, ... ) const
+{
+ // see header file for function documentation
+ int iResult=0;
+
+ va_list args;
+ va_start(args, line);
+
+ // logging function needs to be const in order to be called from const member functions
+ // without problems. But at this point we face the problem with virtual members which
+ // are not necessarily const.
+ AliHLTComponent* nonconst=const_cast<AliHLTComponent*>(this);
+ AliHLTLogging::SetLogString("%s (%s, %p): ",
+ fChainId[0]!=0?fChainId.c_str():nonconst->GetComponentID(),
+ nonconst->GetComponentID(), this);
+ iResult=SendMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args, true /*append*/));
+ va_end(args);
+
+ return iResult;
+}
+
+int AliHLTComponent::ScanECSParam(const char* ecsParam)
+{
+ // see header file for function documentation
+
+ // format of the parameter string from ECS
+ // <command>;<parameterkey>=<parametervalue>;<parameterkey>=<parametervalue>;...
+ // search for a subset of the parameterkeys
+ int iResult=0;
+ TString string=ecsParam;
+ TObjArray* parameter=string.Tokenize(";");
+ if (parameter) {
+ for (int i=0; i<parameter->GetEntries(); i++) {
+ TString entry=((TObjString*)parameter->At(i))->GetString();
+ HLTDebug("scanning ECS entry: %s", entry.Data());
+ TObjArray* entryParams=entry.Tokenize("=");
+ if (entryParams) {
+ if (entryParams->GetEntries()>1) {
+ if ((((TObjString*)entryParams->At(0))->GetString()).CompareTo("CTP_TRIGGER_CLASS")==0) {
+ int result=InitCTPTriggerClasses((((TObjString*)entryParams->At(1))->GetString()).Data());
+ if (iResult>=0 && result<0) iResult=result;
+ } else {
+ // TODO: scan the other parameters
+ // e.g. consistency check of run number
+ }
+ }
+ delete entryParams;
+ }
+ }
+ delete parameter;
+ }
+
+ return iResult;
+}
+
+int AliHLTComponent::SetupCTPData()
+{
+ // see header file for function documentation
+ if (fpCTPData) delete fpCTPData;
+ fpCTPData=new AliHLTCTPData;
+ if (!fpCTPData) return -ENOMEM;
+ return 0;
+}
+
+int AliHLTComponent::InitCTPTriggerClasses(const char* ctpString)
+{
+ // see header file for function documentation
+ if (!fpCTPData) return 0; // silently accept as the component has to announce that it want's the CTP info
+ return fpCTPData->InitCTPTriggerClasses(ctpString);
+}
+
+bool AliHLTComponent::EvaluateCTPTriggerClass(const char* expression, AliHLTComponentTriggerData& trigData) const
+{
+ // see header file for function documentation
+ if (!fpCTPData) {
+ static bool bWarningThrown=false;
+ if (!bWarningThrown) HLTError("Trigger classes not initialized, use SetupCTPData from DoInit()");
+ bWarningThrown=true;
+ return false;
+ }
+
+ return fpCTPData->EvaluateCTPTriggerClass(expression, trigData);
+}