// $Id$
-// splitted from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project *
- * ALICE Experiment at CERN, All rights reserved. *
- * *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
- * for The ALICE HLT Project. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. It is *
- * provided "as is" without express or implied warranty. *
- **************************************************************************/
-
-/** @file AliHLTConfigurationHandler.cxx
- @author Matthias Richter
- @date
- @brief Implementation of HLT tasks.
-*/
-
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
-#if __GNUC__>= 3
-using namespace std;
-#endif
+// split from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47
+///**************************************************************************
+///* This file is property of and copyright by the *
+///* ALICE Experiment at CERN, All rights reserved. *
+///* *
+///* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
+///* for The ALICE HLT Project. *
+///* *
+///* Permission to use, copy, modify and distribute this software and its *
+///* documentation strictly for non-commercial purposes is hereby granted *
+///* without fee, provided that the above copyright notice appears in all *
+///* copies and that both the copyright notice and this permission notice *
+///* appear in the supporting documentation. The authors make no claims *
+///* about the suitability of this software for any purpose. It is *
+///* provided "as is" without express or implied warranty. *
+///**************************************************************************/
+
+/// @file AliHLTConfigurationHandler.cxx
+/// @author Matthias Richter
+/// @date
+/// @brief Implementation of HLT tasks.
+///
#include <cerrno>
#include <iostream>
AliHLTConfigurationHandler::AliHLTConfigurationHandler()
: AliHLTLogging()
, fgListConfigurations()
+ , fgListScheduledRegistrations()
, fFlags(0)
{
- // see header file for class documentation
- // or
- // refer to README to build package
- // or
- // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+ // constructor
+ //
+ // Global Handling of HLT configurations.
+ //
+ // This class implements the global handling of @ref AliHLTConfiguration objects.
+ // It is a list of all configuration descriptors currently available in the system.
+ // Each @ref AliHLTConfiguration object is registered automatically with the
+ // handler and put into the list.
SetLocalLoggingLevel(kHLTLogInfo);
}
AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
{
- // see header file for function documentation
+ // destructor
TObjLink* lnk=NULL;
while ((lnk=fgListConfigurations.FirstLink())!=NULL) {
AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject();
fgListConfigurations.Remove(lnk);
delete pConf;
}
+ fgListScheduledRegistrations.Delete();
}
AliHLTConfigurationHandler* AliHLTConfigurationHandler::fgpInstance=NULL;
AliHLTConfigurationHandler* AliHLTConfigurationHandler::CreateHandler()
{
- // see header file for class documentation
+ // create global handler instance
if (!fgpInstance) fgpInstance=new AliHLTConfigurationHandler;
fgNofInstances++;
return fgpInstance;
int AliHLTConfigurationHandler::Destroy()
{
- // see header file for class documentation
+ // destroy instance
int nofInstances=0;
if (fgpInstance==this) {
nofInstances=--fgNofInstances;
int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf)
{
- // see header file for function documentation
+ // register a configuration
int iResult=0;
if (pConf) {
- AliHLTConfiguration* pExisting=NULL;
- if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
- AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
- fgListConfigurations.Add(pClone);
- HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
-
- // mark all configurations with unresolved dependencies for re-evaluation
- TObjLink* lnk=fgListConfigurations.FirstLink();
- while (lnk) {
- AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
- if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
- pSrc->InvalidateSources();
- }
- lnk=lnk->Next();
- }
- } else {
- if ((*pExisting)!=(*pConf)) {
- iResult=-EEXIST;
- HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
+ AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
+ if (IsActive()) {
+ AliHLTConfiguration* pExisting=NULL;
+ if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
+ fgListConfigurations.Add(pClone);
+ HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
+
+ // mark all configurations with unresolved dependencies for re-evaluation
+ TObjLink* lnk=fgListConfigurations.FirstLink();
+ while (lnk) {
+ AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
+ if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
+ pSrc->InvalidateSources();
+ }
+ lnk=lnk->Next();
+ }
+ } else {
+ if ((*pExisting)!=(*pConf)) {
+ iResult=-EEXIST;
+ HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
+ }
}
+ } else if (IsScheduling()) {
+ fgListScheduledRegistrations.Add(pClone);
}
} else {
iResult=-EINVAL;
int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
{
- // see header file for function documentation
+ // create configuration
int iResult=0;
+ // if this handler is the global instance the configuration is added
+ // automatically in the creation of the AliHLTConfiguration object
+ // the global instance must be deactivated otherwise in order to just create
+ // the object and then add it to THIS handler
+ bool bIamGlobal=fgpInstance==this;
+ if (!bIamGlobal && fgpInstance) {
+ // deactivate the automatic registration in the global handler
+ fgpInstance->Deactivate(false);
+ }
AliHLTConfiguration* pConf= new AliHLTConfiguration(id, component, sources, arguments);
if (pConf) {
+ if (bIamGlobal) {
// the configuration will be registered automatically, if this failes the configuration
// is missing -> delete it
if (FindConfiguration(id)==NULL) {
pConf=NULL;
iResult=-EEXIST;
}
+ } else {
+ RegisterConfiguration(pConf);
+ }
} else {
HLTError("system error: object allocation failed");
iResult=-ENOMEM;
}
+ if (!bIamGlobal && fgpInstance) {
+ // deactivate the automatic registration in the global handler
+ fgpInstance->Activate();
+ }
return iResult;
}
void AliHLTConfigurationHandler::PrintConfigurations()
{
- // see header file for function documentation
+ // print information
HLTLogKeyword("configuration listing");
HLTMessage("registered configurations:");
TObjLink *lnk = fgListConfigurations.FirstLink();
int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
{
- // see header file for function documentation
+ // remove configuration from registry
int iResult=0;
if (id) {
AliHLTConfiguration* pConf=NULL;
int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
{
- // see header file for function documentation
+ // remove configuration from registry
int iResult=0;
if (pConf) {
// remove the configuration from the list
AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* id)
{
- // see header file for function documentation
+ // find configuration by id
AliHLTConfiguration* pConf=NULL;
if (id) {
pConf=(AliHLTConfiguration*)fgListConfigurations.FindObject(id);
return pConf;
}
+int AliHLTConfigurationHandler::Deactivate(bool schedule)
+{
+ // deactivate handler
+ fFlags|=kInactive;
+ if (schedule)
+ fFlags|=kScheduling;
+ return 0;
+}
+
+int AliHLTConfigurationHandler::Activate()
+{
+ // activate handler
+ fFlags&=~kInactive;
+ if (IsScheduling()) {
+ fFlags&=~kScheduling;
+ TObjLink *lnk = fgListScheduledRegistrations.FirstLink();
+ while (lnk) {
+ RegisterConfiguration((AliHLTConfiguration*)lnk->GetObject());
+ lnk = lnk->Next();
+ }
+ ClearScheduledRegistrations();
+ }
+ return 0;
+}
+
int AliHLTConfigurationHandler::MissedRegistration(const char* name)
{
/// indicate a failed attempt to register because of unavailable global instance