various fixes in the HLTOUT treatment
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERLibManager.cxx
index 3b34994..6850fb1 100644 (file)
@@ -41,6 +41,8 @@ ClassImp(AliHLTHOMERLibManager)
 AliHLTHOMERLibManager::AliHLTHOMERLibManager()
   :
   fLibraryStatus(0),
+  fFctCreateReaderFromTCPPort(NULL),
+  fFctCreateReaderFromTCPPorts(NULL),
   fFctCreateReaderFromBuffer(NULL),
   fFctDeleteReader(NULL),
   fFctCreateWriter(NULL),
@@ -58,7 +60,41 @@ AliHLTHOMERLibManager::~AliHLTHOMERLibManager()
   // see header file for class documentation
 }
 
-AliHLTHOMERReader* AliHLTHOMERLibManager::OpenReader(const AliHLTUInt8_t* pBuffer, int size)
+AliHLTHOMERReader* AliHLTHOMERLibManager::OpenReader(const char* hostname, unsigned short port )
+{
+  // see header file for class documentation
+  if (fLibraryStatus<0) return NULL;
+
+  if (fLibraryStatus==0) {
+    fLibraryStatus=LoadHOMERLibrary();
+  }
+  
+  AliHLTHOMERReader* pReader=NULL;
+  if (fFctCreateReaderFromTCPPort!=NULL && (pReader=(((AliHLTHOMERReaderCreateFromTCPPort_t)fFctCreateReaderFromTCPPort)(hostname, port)))==NULL) {
+    //HLTError("can not create instance of HOMER reader (function %p)", fFctCreateReaderFromTCPPort);
+  }
+  
+  return pReader;
+}
+
+AliHLTHOMERReader* AliHLTHOMERLibManager::OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports)
+{
+  // see header file for class documentation
+  if (fLibraryStatus<0) return NULL;
+
+  if (fLibraryStatus==0) {
+    fLibraryStatus=LoadHOMERLibrary();
+  }
+  
+  AliHLTHOMERReader* pReader=NULL;
+  if (fFctCreateReaderFromTCPPorts!=NULL && (pReader=(((AliHLTHOMERReaderCreateFromTCPPorts_t)fFctCreateReaderFromTCPPorts)(tcpCnt, hostnames, ports)))==NULL) {
+    //HLTError("can not create instance of HOMER reader (function %p)", fFctCreateReaderFromTCPPorts);
+  }
+  
+  return pReader;
+}
+
+AliHLTHOMERReader* AliHLTHOMERLibManager::OpenReaderBuffer(const AliHLTUInt8_t* pBuffer, int size)
 {
   // see header file for class documentation
   if (fLibraryStatus<0) return NULL;
@@ -69,7 +105,7 @@ AliHLTHOMERReader* AliHLTHOMERLibManager::OpenReader(const AliHLTUInt8_t* pBuffe
   
   AliHLTHOMERReader* pReader=NULL;
   if (fFctCreateReaderFromBuffer!=NULL && (pReader=(((AliHLTHOMERReaderCreateFromBuffer_t)fFctCreateReaderFromBuffer)(pBuffer, size)))==NULL) {
-    HLTError("can not create instance of HOMER reader (function %p)", fFctCreateReaderFromBuffer);
+    //HLTError("can not create instance of HOMER reader (function %p)", fFctCreateReaderFromBuffer);
   }
   
   return pReader;
@@ -101,9 +137,9 @@ AliHLTHOMERWriter* AliHLTHOMERLibManager::OpenWriter()
   }
   
   AliHLTHOMERWriter* pWriter=NULL;
-//   if (fFctCreateWriter!=NULL && (pWriter=(((AliHLTHOMERWriterCreate_t)fFctCreateWriter)()))==NULL) {
+  if (fFctCreateWriter!=NULL && (pWriter=(((AliHLTHOMERWriterCreate_t)fFctCreateWriter)()))==NULL) {
 //     HLTError("can not create instance of HOMER writer (function %p)", fFctCreateWriter);
-//   }
+  }
   
   return pWriter;
 }
@@ -133,8 +169,7 @@ int AliHLTHOMERLibManager::LoadHOMERLibrary()
   do {
     TString libs = gSystem->GetLibraries();
     if (libs.Contains(*library) ||
-       (gSystem->Load(*library)) > 0) {
-      HLTDebug("%s (is) loaded", *library);
+       (gSystem->Load(*library)) >= 0) {
       iResult=1;
       break;
     }
@@ -150,23 +185,30 @@ int AliHLTHOMERLibManager::LoadHOMERLibrary()
       (*fctInfo)(date, time);
       if (!date) date="unknown";
       if (!time) time="unknown";
-      HLTInfo("%s build on %s (%s)", *library, date, time);
+      //HLTInfo("%s build on %s (%s)", *library, date, time);
     } else {
-      HLTInfo("no build info available for %s", *library);
+      //HLTInfo("no build info available for %s", *library);
     }
 
+    fFctCreateReaderFromTCPPort=gSystem->DynFindSymbol(*library, ALIHLTHOMERREADER_CREATE_FROM_TCPPORT);
+    fFctCreateReaderFromTCPPorts=gSystem->DynFindSymbol(*library, ALIHLTHOMERREADER_CREATE_FROM_TCPPORTS);
     fFctCreateReaderFromBuffer=gSystem->DynFindSymbol(*library, ALIHLTHOMERREADER_CREATE_FROM_BUFFER);
     fFctDeleteReader=gSystem->DynFindSymbol(*library, ALIHLTHOMERREADER_DELETE);
     fFctCreateWriter=gSystem->DynFindSymbol(*library, ALIHLTHOMERWRITER_CREATE);
     fFctDeleteWriter=gSystem->DynFindSymbol(*library, ALIHLTHOMERWRITER_DELETE);
-    if (fFctCreateReaderFromBuffer==NULL || fFctDeleteReader==NULL ||
-       fFctCreateWriter==NULL || fFctDeleteWriter==NULL) {
+    if (fFctCreateReaderFromTCPPort==NULL ||
+       fFctCreateReaderFromTCPPorts==NULL ||
+       fFctCreateReaderFromBuffer==NULL || 
+       fFctDeleteReader==NULL ||
+       fFctCreateWriter==NULL ||
+       fFctDeleteWriter==NULL) {
       iResult=-ENOSYS;
     } else {
-      HLTDebug("%s: create fct %p, delete fct %p", *library, fFctCreateReaderFromBuffer, fFctDeleteReader);
     }
   }
   if (iResult<0 || *library==NULL) {
+    fFctCreateReaderFromTCPPort=NULL;
+    fFctCreateReaderFromTCPPorts=NULL;
     fFctCreateReaderFromBuffer=NULL;
     fFctDeleteReader=NULL;
     fFctCreateWriter=NULL;