]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTMisc.cxx
Fixing generation of bit mask for TObject::fBits field.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTMisc.cxx
CommitLineData
2b545cdd 1// $Id$
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 AliHLTMisc.h
20/// @author Matthias Richter
21/// @date 2009-07-07
22/// @brief Definition of various glue functions implemented in dynamically
23/// loaded libraries
24
25#include "AliHLTMisc.h"
26#include "AliHLTLogging.h"
27#include "TClass.h"
28#include "TSystem.h"
29
30/** ROOT macro for the implementation of ROOT specific class methods */
31ClassImp(AliHLTMisc);
32
33AliHLTMisc::AliHLTMisc()
34{
35 // see header file for function documentation
36}
37
38AliHLTMisc::~AliHLTMisc()
39{
40 // see header file for function documentation
41}
42
43AliHLTMisc* AliHLTMisc::fgInstance=NULL;
44
45template<class T>
46T* AliHLTMisc::LoadInstance(const T* /*t*/, const char* classname, const char* library)
47{
48 // see header file for function documentation
49 int iLibResult=0;
50 T* pInstance=NULL;
51 AliHLTLogging log;
52 TClass* pCl=NULL;
53 ROOT::NewFunc_t pNewFunc=NULL;
54 do {
55 pCl=TClass::GetClass(classname);
56 } while (!pCl && (iLibResult=gSystem->Load(library))==0);
57 if (iLibResult>=0) {
58 if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
59 void* p=(*pNewFunc)(NULL);
60 if (p) {
61 pInstance=reinterpret_cast<T*>(p);
62 if (!pInstance) {
63 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "type cast (%s) to instance failed", classname);
64 }
65 } else {
66 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not create instance of type %s from class descriptor", classname);
67 }
68 } else {
69 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not find class descriptor %s", classname);
70 }
71 } else {
72 log.Logging(kHLTLogError, "AliHLTMisc::LoadInstance", "HLT Analysis", "can not load %s library in order to find class descriptor %s", library, classname);
73 }
74 return pInstance;
75}
76
77AliHLTMisc& AliHLTMisc::Instance()
78{
79 // see header file for function documentation
80 if (!fgInstance) {
81 fgInstance=LoadInstance((AliHLTMisc*)NULL, "AliHLTMiscImplementation", ALIHLTMISC_LIBRARY);
82 }
83 if (!fgInstance) {
84 AliHLTLogging log;
85 fgInstance=new AliHLTMisc;
86 log.Logging(kHLTLogError, "AliHLTMisc::Instance", "HLT Analysis", "falling back to default AliHLTMisc instance");
87 }
88 return *fgInstance;
89}
90
91int AliHLTMisc::InitCDB(const char* /*cdbpath*/)
92{
93 // see header file for function documentation
94 return -EFAULT;
95}
96
97int AliHLTMisc::SetCDBRunNo(int /*runNo*/)
98{
99 // see header file for function documentation
100 return -EFAULT;
101}
102
103AliCDBEntry* AliHLTMisc::LoadOCDBEntry(const char* /*path*/, int /*runNo*/, int /*version*/, int /*subVersion*/)
104{
105 // see header file for function documentation
106 return NULL;
107}
108
109TObject* AliHLTMisc::ExtractObject(AliCDBEntry* /*entry*/)
110{
111 // see header file for function documentation
112 return NULL;
113}
5bc495ef 114
115ostream &operator<<(ostream &out, const AliHLTComponentDataType &dt)
116{
117 // printout of AliHLTComponentDataType struct
118 char id[kAliHLTComponentDataTypefIDsize+1];
119 strncpy(id, dt.fID, kAliHLTComponentDataTypefIDsize);
120 id[kAliHLTComponentDataTypefIDsize]=0;
121 char origin[kAliHLTComponentDataTypefOriginSize+1];
122 strncpy(origin, dt.fOrigin, kAliHLTComponentDataTypefOriginSize);
123 origin[kAliHLTComponentDataTypefOriginSize]=0;
124 out << "{" << id << ":" << origin << "}";
125 return out;
126}