]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx
Using fNContrubutors in AliAODVertex for SPD vertices.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLT_C_Component_WrapperInterface.cxx
index ce4657a090e0a76be8a877debc8e527fdffbdc57..20092317e884717d55b63e8fa4c1aa58fa75fd60 100644 (file)
@@ -1,21 +1,21 @@
 // $Id$
 
-/**************************************************************************
- * 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>        *
- *                  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   *
- * 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.                  *
- **************************************************************************/
+//**************************************************************************
+//* 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>        *
+//*                  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   *
+//* 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   AliHLT_C_Component_WrapperInterface.cxx
     @author Matthias Richter, Timm Steinbeck
@@ -30,9 +30,12 @@ using namespace std;
 #include "AliHLT_C_Component_WrapperInterface.h"
 #include "AliHLTComponentHandler.h"
 #include "AliHLTComponent.h"
+#include "AliHLTMisc.h"
 #include <errno.h>
 
 static AliHLTComponentHandler *gComponentHandler_C = NULL;
+static AliHLTRunDesc gRunDesc=kAliHLTVoidRunDesc;
+static char* gRunType=NULL;
 
 int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* comenv )
 {
@@ -40,7 +43,25 @@ int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* comenv )
     {
       return EINPROGRESS;
     }
-  gComponentHandler_C = new AliHLTComponentHandler(comenv);
+
+  // July 2008  
+  // Due to a bug in the SimpleComponentWrapper and AliRootWrapperSubscriber
+  // the fStructSize member was never initialized and we can not use this
+  // method of synchronizing different versions.
+  // This interface is now deprecated, only kept for backward compatibility.
+  // All function pointers are explicitely mapped to the new structure.
+
+  AliHLTAnalysisEnvironment mappedEnv;
+  memset(&mappedEnv, 0, sizeof(mappedEnv));
+  mappedEnv.fStructSize=sizeof(mappedEnv);
+  if (comenv) {
+    mappedEnv.fParam               = comenv->fParam;
+    mappedEnv.fAllocMemoryFunc     = comenv->fAllocMemoryFunc;
+    mappedEnv.fGetEventDoneDataFunc= comenv->fGetEventDoneDataFunc;
+    mappedEnv.fLoggingFunc         = comenv->fLoggingFunc;
+  }
+
+  gComponentHandler_C = new AliHLTComponentHandler(&mappedEnv);
   if ( !gComponentHandler_C )
     return EFAULT;
   gComponentHandler_C->InitAliLogTrap(gComponentHandler_C);
@@ -90,7 +111,14 @@ int AliHLT_C_CreateComponent( const char* componentType, void* environParam, int
   AliHLTComponent* comp=NULL;
   const char* cdbPath = getenv("ALIHLT_HCDBDIR");
   if (!cdbPath) cdbPath = getenv("ALICE_ROOT");
-  int ret = gComponentHandler_C->CreateComponent( componentType, environParam, argc, argv, comp, cdbPath);
+  int ret = gComponentHandler_C->CreateComponent( componentType, comp);
+  if (ret>=0 && comp) {
+    AliHLTMisc::Instance().InitCDB(cdbPath);
+    AliHLTMisc::Instance().SetCDBRunNo(gRunDesc.fRunNo);
+    comp->SetRunDescription(&gRunDesc, gRunType);
+    const AliHLTAnalysisEnvironment* comenv=gComponentHandler_C->GetEnvironment();
+    ret=comp->Init(comenv, environParam, argc, argv);
+  }
   *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
 
   return ret;
@@ -112,9 +140,15 @@ int AliHLT_C_SetRunDescription(const AliHLTRunDesc* desc, const char* runType)
   if (desc->fStructSize<sizeof(AliHLTUInt32_t)) return -EINVAL;
   if (!gComponentHandler_C) return ENXIO;
 
-  AliHLTRunDesc internalDesc=kAliHLTVoidRunDesc;
-  memcpy(&internalDesc, desc, desc->fStructSize<sizeof(internalDesc)?desc->fStructSize:sizeof(internalDesc));
-  return gComponentHandler_C->SetRunDescription(&internalDesc, runType);
+  memcpy(&gRunDesc, desc, desc->fStructSize<sizeof(gRunDesc)?desc->fStructSize:sizeof(gRunDesc));
+  gRunDesc.fStructSize=sizeof(gRunDesc);
+  if (gRunType) delete [] gRunType;
+  gRunType=NULL;
+  if (runType) {
+    gRunType=new char[strlen(runType)+1];
+    if (gRunType) strcpy(gRunType, runType);
+  }
+  return 0;
 }
 
 int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponentEventData* evtData, const AliHLTComponentBlockData* blocks,