]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx
initialization of CDB in wrapper interface;added treatment of reconfiguration event
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLT_C_Component_WrapperInterface.cxx
index 1fac7bef23b5df253513851d9892243751150a8e..e4329d96659bcdba214ff22cafaa387ba9f040b8 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * ALICE Experiment at CERN, All rights reserved.                         *
  *                                                                        *
- * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
- *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
- *          Artur Szostak <artursz@iafrica.com>                           *
- *          for The ALICE Off-line Project.                               *
+ * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+ *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
+ *                  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   *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-// pure C interface to the AliRoot HLT component handler                     //
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
+/** @file   AliHLT_C_Component_WrapperInterface.cxx
+    @author Matthias Richter, Timm Steinbeck
+    @date   
+    @brief  Pure C interface to the AliRoot HLT component handler
+*/
 
 #if __GNUC__>= 3
 using namespace std;
@@ -41,10 +41,11 @@ int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ )
     {
       return EINPROGRESS;
     }
-  gComponentHandler_C = new AliHLTComponentHandler();
+  gComponentHandler_C = new AliHLTComponentHandler(environ);
   if ( !gComponentHandler_C )
     return EFAULT;
-  gComponentHandler_C->SetEnvironment( environ );
+  gComponentHandler_C->InitAliLogTrap(gComponentHandler_C);
+  gComponentHandler_C->AnnounceVersion();
   return 0;
 }
 
@@ -65,20 +66,37 @@ int AliHLT_C_Component_LoadLibrary( const char* libraryPath )
   return gComponentHandler_C->LoadLibrary( libraryPath );
 }
 
-int AliHLT_C_Component_UnloadLibrary( const char* libraryPath )
+int AliHLT_C_Component_UnloadLibrary( const char* /*libraryPath*/ )
 {
   if ( !gComponentHandler_C )
     return ENXIO;
-  return gComponentHandler_C->UnloadLibrary( libraryPath );
+  // Matthias 26.10.2007
+  // Unloading of libraries has to be re-worked. It has been commented out here
+  // since the libraries will be unloaded at the destruction of the component
+  // handler instance anyway. So it has no effect to the operation in PubSub.
+  // With the introduction of the dynamic component registration via module
+  // agents we run into trouble when cleaning up the samples managed by the
+  // component handler. Destruction of the sample objects is done AFTER
+  // unloading of the library and thus the destructor is not present any 
+  // more.
+  //return gComponentHandler_C->UnloadLibrary( libraryPath );
+  return 0;
 }
 
 int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponentHandle* handle )
 {
   if ( !gComponentHandler_C )
     return ENXIO;
+  if ( !handle ) return EINVAL;
   AliHLTComponent* comp;
   int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp );
+  if (comp) {
+    const char* cdbPath = getenv("ALIHLT_HCDBDIR");
+    if (!cdbPath) cdbPath = getenv("ALICE_ROOT");
+    if (cdbPath) comp->InitCDB(cdbPath);
+  }
   *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
+
   return ret;
 }
 
@@ -86,7 +104,10 @@ void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle )
 {
   if ( !handle )
     return;
-  delete reinterpret_cast<AliHLTComponent*>( handle );
+  
+  AliHLTComponent* pComp=reinterpret_cast<AliHLTComponent*>( handle );
+  pComp->Deinit();
+  delete pComp;
 }
 
 int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponent_EventData* evtData, const AliHLTComponent_BlockData* blocks,