ROOT logo
// $Id: AliRawHLTManager.cxx 23039 2007-12-13 20:53:02Z richterm $

//**************************************************************************
//* 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>        *
//*                  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   AliRawHLTManager.cxx
    @author Matthias Richter
    @date   
    @brief  dynamic generation of HLT RAW readers and streams
*/

#include "AliRawHLTManager.h"
#include "AliLog.h"
#include "TSystem.h"
#include "TClass.h"

ClassImp(AliRawHLTManager)

AliRawHLTManager::AliRawHLTManager()
{
  // The class gives dynamic access to creater methods for HLT RAW readers and
  // streams without any library dependencies to HLT libraries.
  //
  // The AliRawReaderHLT allows the redirection of input from the HLT DDL links
  // to the detector equipment ids. To access the data, the AliRawReaderHLT
  // needs a valid RAW reader (parent).
  // usage:
  // AliRawReader* pHLTReader=AliRawHLTManager::CreateRawReaderHLT(pParent, "TPC");
}

AliRawHLTManager::~AliRawHLTManager()
{
  // destructor
}

int AliRawHLTManager::fLibraryStatus=kUnloaded;
AliRawReaderHLTCreateInstance_t AliRawHLTManager::fFctCreateRawReaderHLT=NULL;
void* AliRawHLTManager::fFctCreateRawStream=NULL;

AliRawReader* AliRawHLTManager::CreateRawReaderHLT(AliRawReader* pParent, const char* detectors)
{
  // see header file for class documentation
  if (fLibraryStatus==kUnloaded) fLibraryStatus=LoadLibrary();
  if (fLibraryStatus==kUnavailable) return NULL;

  if (!fFctCreateRawReaderHLT) {
    AliErrorClass("internal error, library loaded but function entry not known");
    return NULL;
  }
  return ((AliRawReaderHLTCreateInstance_t)fFctCreateRawReaderHLT)(pParent, detectors);
}

TObject* AliRawHLTManager::CreateRawStream(const char* /*className*/)
{
  // see header file for class documentation

  // not yet implemented
  return NULL;
}

int AliRawHLTManager::LoadLibrary()
{
  // see header file for class documentation
  int iResult=kUnavailable;
  if (fLibraryStatus!=kUnloaded) return fLibraryStatus;

  // strictly speaken we do not need a trial counter as gSystem->Load only returns 1 if the
  // library has been loaded. If it was already loaded we get 0 
  int iTrials=0;
  do {
    fFctCreateRawReaderHLT=(AliRawReaderHLTCreateInstance_t)gSystem->DynFindSymbol(ALIHLTREC_LIBRARY, ALIRAWREADERHLT_CREATE_INSTANCE);
  } while (fFctCreateRawReaderHLT==NULL && gSystem->Load(ALIHLTREC_LIBRARY)==0 && iTrials++<1);
  if (fFctCreateRawReaderHLT) {
    iResult=kLoaded;
  } else {
    AliErrorClass(Form("can not find library/entry %s/%s", ALIHLTREC_LIBRARY, ALIRAWREADERHLT_CREATE_INSTANCE));
    iResult=kUnavailable;
  }
  return iResult;
}
 AliRawHLTManager.cxx:1
 AliRawHLTManager.cxx:2
 AliRawHLTManager.cxx:3
 AliRawHLTManager.cxx:4
 AliRawHLTManager.cxx:5
 AliRawHLTManager.cxx:6
 AliRawHLTManager.cxx:7
 AliRawHLTManager.cxx:8
 AliRawHLTManager.cxx:9
 AliRawHLTManager.cxx:10
 AliRawHLTManager.cxx:11
 AliRawHLTManager.cxx:12
 AliRawHLTManager.cxx:13
 AliRawHLTManager.cxx:14
 AliRawHLTManager.cxx:15
 AliRawHLTManager.cxx:16
 AliRawHLTManager.cxx:17
 AliRawHLTManager.cxx:18
 AliRawHLTManager.cxx:19
 AliRawHLTManager.cxx:20
 AliRawHLTManager.cxx:21
 AliRawHLTManager.cxx:22
 AliRawHLTManager.cxx:23
 AliRawHLTManager.cxx:24
 AliRawHLTManager.cxx:25
 AliRawHLTManager.cxx:26
 AliRawHLTManager.cxx:27
 AliRawHLTManager.cxx:28
 AliRawHLTManager.cxx:29
 AliRawHLTManager.cxx:30
 AliRawHLTManager.cxx:31
 AliRawHLTManager.cxx:32
 AliRawHLTManager.cxx:33
 AliRawHLTManager.cxx:34
 AliRawHLTManager.cxx:35
 AliRawHLTManager.cxx:36
 AliRawHLTManager.cxx:37
 AliRawHLTManager.cxx:38
 AliRawHLTManager.cxx:39
 AliRawHLTManager.cxx:40
 AliRawHLTManager.cxx:41
 AliRawHLTManager.cxx:42
 AliRawHLTManager.cxx:43
 AliRawHLTManager.cxx:44
 AliRawHLTManager.cxx:45
 AliRawHLTManager.cxx:46
 AliRawHLTManager.cxx:47
 AliRawHLTManager.cxx:48
 AliRawHLTManager.cxx:49
 AliRawHLTManager.cxx:50
 AliRawHLTManager.cxx:51
 AliRawHLTManager.cxx:52
 AliRawHLTManager.cxx:53
 AliRawHLTManager.cxx:54
 AliRawHLTManager.cxx:55
 AliRawHLTManager.cxx:56
 AliRawHLTManager.cxx:57
 AliRawHLTManager.cxx:58
 AliRawHLTManager.cxx:59
 AliRawHLTManager.cxx:60
 AliRawHLTManager.cxx:61
 AliRawHLTManager.cxx:62
 AliRawHLTManager.cxx:63
 AliRawHLTManager.cxx:64
 AliRawHLTManager.cxx:65
 AliRawHLTManager.cxx:66
 AliRawHLTManager.cxx:67
 AliRawHLTManager.cxx:68
 AliRawHLTManager.cxx:69
 AliRawHLTManager.cxx:70
 AliRawHLTManager.cxx:71
 AliRawHLTManager.cxx:72
 AliRawHLTManager.cxx:73
 AliRawHLTManager.cxx:74
 AliRawHLTManager.cxx:75
 AliRawHLTManager.cxx:76
 AliRawHLTManager.cxx:77
 AliRawHLTManager.cxx:78
 AliRawHLTManager.cxx:79
 AliRawHLTManager.cxx:80
 AliRawHLTManager.cxx:81
 AliRawHLTManager.cxx:82
 AliRawHLTManager.cxx:83
 AliRawHLTManager.cxx:84
 AliRawHLTManager.cxx:85
 AliRawHLTManager.cxx:86
 AliRawHLTManager.cxx:87
 AliRawHLTManager.cxx:88
 AliRawHLTManager.cxx:89
 AliRawHLTManager.cxx:90
 AliRawHLTManager.cxx:91
 AliRawHLTManager.cxx:92
 AliRawHLTManager.cxx:93