Line data Source code
1 : // $Id: AliRawHLTManager.cxx 23039 2007-12-13 20:53:02Z richterm $
2 :
3 : //**************************************************************************
4 : //* This file is property of and copyright by the ALICE HLT Project *
5 : //* ALICE Experiment at CERN, All rights reserved. *
6 : //* *
7 : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 : //* for The ALICE HLT Project. *
9 : //* *
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 : //**************************************************************************
18 :
19 : /** @file AliRawHLTManager.cxx
20 : @author Matthias Richter
21 : @date
22 : @brief dynamic generation of HLT RAW readers and streams
23 : */
24 :
25 : #include "AliRawHLTManager.h"
26 : #include "AliLog.h"
27 : #include "TSystem.h"
28 : #include "TClass.h"
29 :
30 128 : ClassImp(AliRawHLTManager)
31 :
32 : AliRawHLTManager::AliRawHLTManager()
33 0 : {
34 : // The class gives dynamic access to creater methods for HLT RAW readers and
35 : // streams without any library dependencies to HLT libraries.
36 : //
37 : // The AliRawReaderHLT allows the redirection of input from the HLT DDL links
38 : // to the detector equipment ids. To access the data, the AliRawReaderHLT
39 : // needs a valid RAW reader (parent).
40 : // usage:
41 : // AliRawReader* pHLTReader=AliRawHLTManager::CreateRawReaderHLT(pParent, "TPC");
42 0 : }
43 :
44 : AliRawHLTManager::~AliRawHLTManager()
45 0 : {
46 : // destructor
47 0 : }
48 :
49 : int AliRawHLTManager::fLibraryStatus=kUnloaded;
50 : AliRawReaderHLTCreateInstance_t AliRawHLTManager::fFctCreateRawReaderHLT=NULL;
51 : void* AliRawHLTManager::fFctCreateRawStream=NULL;
52 :
53 : AliRawReader* AliRawHLTManager::CreateRawReaderHLT(AliRawReader* pParent, const char* detectors)
54 : {
55 : // see header file for class documentation
56 0 : if (fLibraryStatus==kUnloaded) fLibraryStatus=LoadLibrary();
57 0 : if (fLibraryStatus==kUnavailable) return NULL;
58 :
59 0 : if (!fFctCreateRawReaderHLT) {
60 0 : AliErrorClass("internal error, library loaded but function entry not known");
61 0 : return NULL;
62 : }
63 0 : return ((AliRawReaderHLTCreateInstance_t)fFctCreateRawReaderHLT)(pParent, detectors);
64 0 : }
65 :
66 : TObject* AliRawHLTManager::CreateRawStream(const char* /*className*/)
67 : {
68 : // see header file for class documentation
69 :
70 : // not yet implemented
71 0 : return NULL;
72 : }
73 :
74 : int AliRawHLTManager::LoadLibrary()
75 : {
76 : // see header file for class documentation
77 : int iResult=kUnavailable;
78 0 : if (fLibraryStatus!=kUnloaded) return fLibraryStatus;
79 :
80 : // strictly speaken we do not need a trial counter as gSystem->Load only returns 1 if the
81 : // library has been loaded. If it was already loaded we get 0
82 : int iTrials=0;
83 0 : do {
84 0 : fFctCreateRawReaderHLT=(AliRawReaderHLTCreateInstance_t)gSystem->DynFindSymbol(ALIHLTREC_LIBRARY, ALIRAWREADERHLT_CREATE_INSTANCE);
85 0 : } while (fFctCreateRawReaderHLT==NULL && gSystem->Load(ALIHLTREC_LIBRARY)==0 && iTrials++<1);
86 0 : if (fFctCreateRawReaderHLT) {
87 : iResult=kLoaded;
88 0 : } else {
89 0 : AliErrorClass(Form("can not find library/entry %s/%s", ALIHLTREC_LIBRARY, ALIRAWREADERHLT_CREATE_INSTANCE));
90 : iResult=kUnavailable;
91 : }
92 : return iResult;
93 0 : }
|