]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTConfigurationHandler.cxx
Removing the lib files
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTConfigurationHandler.cxx
index 9b0c228ab89b6f00bca2d44332fd98ad575b7625..bcc78d9f8d42184bbff43ed8d811fa7b44526c04 100644 (file)
@@ -1,36 +1,26 @@
 // $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>
@@ -47,19 +37,23 @@ ClassImp(AliHLTConfigurationHandler)
 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();
@@ -67,6 +61,7 @@ AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
     fgListConfigurations.Remove(lnk);
     delete pConf;
   }
+  fgListScheduledRegistrations.Delete();
 }
 
 AliHLTConfigurationHandler* AliHLTConfigurationHandler::fgpInstance=NULL;
@@ -75,7 +70,7 @@ TMap* AliHLTConfigurationHandler::fgpSubstitutions=NULL;
 
 AliHLTConfigurationHandler* AliHLTConfigurationHandler::CreateHandler()
 {
-  // see header file for class documentation
+  // create global handler instance
   if (!fgpInstance) fgpInstance=new AliHLTConfigurationHandler;
   fgNofInstances++;
   return fgpInstance;
@@ -83,7 +78,7 @@ AliHLTConfigurationHandler* AliHLTConfigurationHandler::CreateHandler()
 
 int AliHLTConfigurationHandler::Destroy()
 {
-  // see header file for class documentation
+  // destroy instance
   int nofInstances=0;
   if (fgpInstance==this) {
     nofInstances=--fgNofInstances;
@@ -100,29 +95,33 @@ int AliHLTConfigurationHandler::Destroy()
 
 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;
@@ -132,10 +131,20 @@ int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf
 
 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) {
@@ -143,16 +152,23 @@ int AliHLTConfigurationHandler::CreateConfiguration(const char* id, const char*
       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();
@@ -185,7 +201,7 @@ void AliHLTConfigurationHandler::Print(const char* option)
 
 int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
 {
-  // see header file for function documentation
+  // remove configuration from registry
   int iResult=0;
   if (id) {
     AliHLTConfiguration* pConf=NULL;
@@ -205,7 +221,7 @@ int AliHLTConfigurationHandler::RemoveConfiguration(const char* id)
 
 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
@@ -228,7 +244,7 @@ int AliHLTConfigurationHandler::RemoveConfiguration(AliHLTConfiguration* pConf)
 
 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); 
@@ -236,6 +252,31 @@ AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* i
   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