]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
bugfix in the CDB initialization from the external interface
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jan 2008 14:11:02 +0000 (14:11 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 30 Jan 2008 14:11:02 +0000 (14:11 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h
HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx
HLT/rec/AliHLTMisc.cxx

index db222bdbeece8d0228a0d405cff24bfd17d4786b..67ddf3eaab42623e7c7e2e00fde68dd587bd74c1 100644 (file)
@@ -78,7 +78,7 @@ AliHLTComponent::AliHLTComponent()
   fMemFiles(),
   fpRunDesc(NULL),
   fpDDLList(NULL),
-  fCDBInitialized(false),
+  fCDBSetRunNoFunc(false),
   fChainId()
 {
   // see header file for class documentation
@@ -203,40 +203,40 @@ int AliHLTComponent::Deinit()
   return iResult;
 }
 
-int AliHLTComponent::InitCDB(const char* cdbPath)
+int AliHLTComponent::InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler)
 {
+  // see header file for function documentation
   int iResult=0;
-  // we presume the library already to be loaded
+  if (cdbPath, pHandler) {
+  // I have to think about separating the library handling from the
+  // component handler. Requiring the component hanlder here is not
+  // the cleanest solution.
+  // We presume the library already to be loaded
   // find the symbol
-  AliHLTComponentHandler cHandler;
-  AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB); 
+  AliHLTMiscInitCDB_t pFunc=(AliHLTMiscInitCDB_t)pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_INIT_CDB);
   if (pFunc) {
-    iResult=(*pFunc)(cdbPath);
-    fCDBInitialized=iResult>=0;
+    if ((iResult=(*pFunc)(cdbPath))>=0) {
+      if (!(fCDBSetRunNoFunc=pHandler->FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO))) {
+       Message(NULL, kHLTLogWarning, "AliHLTComponent::InitCDB", "init CDB",
+               "can not find function to set CDB run no");
+      }
+    }
   } else {
     Message(NULL, kHLTLogError, "AliHLTComponent::InitCDB", "init CDB",
            "can not find initialization function");
     iResult=-ENOSYS;
   }
+  } else {
+    iResult=-EINVAL;
+  }
   return iResult;
 }
 
 int AliHLTComponent::SetCDBRunNo(int runNo)
 {
-  int iResult=0;
-  if (!fCDBInitialized) return iResult;
-  // we presume the library already to be loaded
-  // find the symbol
-  AliHLTComponentHandler cHandler;
-  AliHLTMiscSetCDBRunNo_t pFunc=(AliHLTMiscSetCDBRunNo_t)cHandler.FindSymbol(ALIHLTMISC_LIBRARY, ALIHLTMISC_SET_CDB_RUNNO); 
-  if (pFunc) {
-    iResult=(*pFunc)(runNo);
-  } else {
-    Message(NULL, kHLTLogError, "AliHLTComponent::SetCDBRunNo", "init CDB",
-           "can not find initialization function");
-    iResult=-ENOSYS;
-  }
-  return iResult;
+  // see header file for function documentation
+  if (!fCDBSetRunNoFunc) return 0;
+  return (*((AliHLTMiscSetCDBRunNo_t)fCDBSetRunNoFunc))(runNo);
 }
 
 int AliHLTComponent::DoInit( int /*argc*/, const char** /*argv*/)
@@ -259,6 +259,7 @@ int AliHLTComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId
 
 int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/)
 {
+  // default implementation, childs can overload
   HLTLogKeyword("dummy");
   return 0;
 }
index f4586e6a2976af397afe61f9f076aa80b030a089..e03bcdb03f50b560af84195b3cc2c104caca731e 100644 (file)
@@ -330,9 +330,16 @@ class AliHLTComponent : public AliHLTLogging {
    * override the path initialized at the beginning of the AliRoot reconstruction.
    *
    * The method is used from the external interface in order to set the correct
-   * path when running on-line.
+   * path when running on-line. The function also initializes the function
+   * callback for setting the run no during operation.
+   *
+   * A separation of library and component handling is maybe appropriate in the
+   * future. Using the global component handler here is maybe not the cleanest
+   * solution.
+   * @param cdbPath      path of the CDB
+   * @param pHandler     the component handler used for llibrary handling.
    */
-  int InitCDB(const char* cdbPath);
+  int InitCDB(const char* cdbPath, AliHLTComponentHandler* pHandler);
 
   /**
    * Set the run no for the CDB.
@@ -1190,12 +1197,12 @@ class AliHLTComponent : public AliHLTLogging {
   /** the current DDL list */
   AliHLTEventDDL* fpDDLList;                                       //! transient
 
-  /** indicates that the CDB has been initialized locally */
-  bool fCDBInitialized;                                            //! transient
+  /** external fct to set CDB run no, indicates external CDB initialization */
+  void* fCDBSetRunNoFunc;                                          //! transient
 
   /** id of the component in the analysis chain */
   string fChainId;                                                 //! transient
 
-  ClassDef(AliHLTComponent, 4)
+  ClassDef(AliHLTComponent, 5)
 };
 #endif
index e4329d96659bcdba214ff22cafaa387ba9f040b8..9f009c1285cea486edf8ce67e8391d86e4501059 100644 (file)
@@ -93,7 +93,7 @@ int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, in
   if (comp) {
     const char* cdbPath = getenv("ALIHLT_HCDBDIR");
     if (!cdbPath) cdbPath = getenv("ALICE_ROOT");
-    if (cdbPath) comp->InitCDB(cdbPath);
+    if (cdbPath) comp->InitCDB(cdbPath, gComponentHandler_C);
   }
   *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
 
index 62fb593ad0e7fc4f80f3780390cfac242bebb806..9dfbeb35bceac796c29994567c4043a6b713c102 100644 (file)
@@ -34,7 +34,6 @@ int AliHLTMiscInitCDB(const char* cdbpath)
   if (!pCDB) {
     log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance");
   } else {
-    pCDB->SetRun(0); // This will be retrieved during the SOR event
     pCDB->SetDefaultStorage(cdbpath);
     log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB);
   }