3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTHOMERLibManager.cxx
20 @author Matthias Richter
22 @brief dynamic HLT HOMER reader/writer generation and destruction. */
24 // see header file for class documentation
26 // refer to README to build package
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32 #include "AliHLTHOMERLibManager.h"
33 #include "AliHLTHOMERReader.h"
34 #include "AliHLTHOMERWriter.h"
38 /** ROOT macro for the implementation of ROOT specific class methods */
39 ClassImp(AliHLTHOMERLibManager)
41 AliHLTHOMERLibManager::AliHLTHOMERLibManager()
44 fFctCreateReaderFromBuffer(NULL),
45 fFctDeleteReader(NULL),
46 fFctCreateWriter(NULL),
47 fFctDeleteWriter(NULL)
49 // see header file for class documentation
51 // refer to README to build package
53 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
56 AliHLTHOMERLibManager::~AliHLTHOMERLibManager()
58 // see header file for class documentation
61 AliHLTHOMERReader* AliHLTHOMERLibManager::OpenReader(const AliHLTUInt8_t* pBuffer, int size)
63 // see header file for class documentation
64 if (fLibraryStatus<0) return NULL;
66 if (fLibraryStatus==0) {
67 fLibraryStatus=LoadHOMERLibrary();
70 AliHLTHOMERReader* pReader=NULL;
71 if (fFctCreateReaderFromBuffer!=NULL && (pReader=(((AliHLTHOMERReaderCreateFromBuffer_t)fFctCreateReaderFromBuffer)(pBuffer, size)))==NULL) {
72 HLTError("can not create instance of HOMER reader (function %p)", fFctCreateReaderFromBuffer);
78 int AliHLTHOMERLibManager::DeleteReader(AliHLTHOMERReader* pReader)
80 // see header file for class documentation
81 if (fLibraryStatus<0) return fLibraryStatus;
83 if (fLibraryStatus==0) {
84 fLibraryStatus=LoadHOMERLibrary();
87 if (fFctDeleteReader!=NULL) {
88 ((AliHLTHOMERReaderDelete_t)fFctDeleteReader)(pReader);
94 AliHLTHOMERWriter* AliHLTHOMERLibManager::OpenWriter()
96 // see header file for class documentation
97 if (fLibraryStatus<0) return NULL;
99 if (fLibraryStatus==0) {
100 fLibraryStatus=LoadHOMERLibrary();
103 AliHLTHOMERWriter* pWriter=NULL;
104 // if (fFctCreateWriter!=NULL && (pWriter=(((AliHLTHOMERWriterCreate_t)fFctCreateWriter)()))==NULL) {
105 // HLTError("can not create instance of HOMER writer (function %p)", fFctCreateWriter);
111 int AliHLTHOMERLibManager::DeleteWriter(AliHLTHOMERWriter* pWriter)
113 // see header file for class documentation
114 if (fLibraryStatus<0) return fLibraryStatus;
116 if (fLibraryStatus==0) {
117 fLibraryStatus=LoadHOMERLibrary();
120 if (fFctDeleteWriter!=NULL) {
121 ((AliHLTHOMERWriterDelete_t)fFctDeleteWriter)(pWriter);
127 int AliHLTHOMERLibManager::LoadHOMERLibrary()
129 // see header file for class documentation
131 const char* libraries[]={"libAliHLTHOMER.so", "libHOMER.so", NULL};
132 const char** library=&libraries[0];
134 TString libs = gSystem->GetLibraries();
135 if (libs.Contains(*library) ||
136 (gSystem->Load(*library)) > 0) {
137 HLTDebug("%s (is) loaded", *library);
141 } while (*(++library)!=NULL);
143 if (iResult>0 && *library!=NULL) {
144 // print compile info
145 typedef void (*CompileInfo)( char*& date, char*& time);
146 CompileInfo fctInfo=(CompileInfo)gSystem->DynFindSymbol(*library, "CompileInfo");
150 (*fctInfo)(date, time);
151 if (!date) date="unknown";
152 if (!time) time="unknown";
153 HLTInfo("%s build on %s (%s)", *library, date, time);
155 HLTInfo("no build info available for %s", *library);
158 fFctCreateReaderFromBuffer=gSystem->DynFindSymbol(*library, ALIHLTHOMERREADER_CREATE_FROM_BUFFER);
159 fFctDeleteReader=gSystem->DynFindSymbol(*library, ALIHLTHOMERREADER_DELETE);
160 fFctCreateWriter=gSystem->DynFindSymbol(*library, ALIHLTHOMERWRITER_CREATE);
161 fFctDeleteWriter=gSystem->DynFindSymbol(*library, ALIHLTHOMERWRITER_DELETE);
162 if (fFctCreateReaderFromBuffer==NULL || fFctDeleteReader==NULL ||
163 fFctCreateWriter==NULL || fFctDeleteWriter==NULL) {
166 HLTDebug("%s: create fct %p, delete fct %p", *library, fFctCreateReaderFromBuffer, fFctDeleteReader);
169 if (iResult<0 || *library==NULL) {
170 fFctCreateReaderFromBuffer=NULL;
171 fFctDeleteReader=NULL;
172 fFctCreateWriter=NULL;
173 fFctDeleteWriter=NULL;