]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTMisc.cxx
fixing compilation errors
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTMisc.cxx
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 */
31 ClassImp(AliHLTMisc);
32
33 AliHLTMisc::AliHLTMisc()
34 {
35   // see header file for function documentation
36 }
37
38 AliHLTMisc::~AliHLTMisc()
39 {
40   // see header file for function documentation
41 }
42
43 AliHLTMisc* AliHLTMisc::fgInstance=NULL;
44
45 template<class T>
46 T* 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
77 AliHLTMisc& 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
91 int AliHLTMisc::InitCDB(const char* /*cdbpath*/)
92 {
93   // default method, functionality is implemented in the child class
94   return -EFAULT;
95 }
96
97 int AliHLTMisc::SetCDBRunNo(int /*runNo*/)
98 {
99   // default method, functionality is implemented in the child class
100   return -EFAULT;
101 }
102
103 AliCDBEntry* AliHLTMisc::LoadOCDBEntry(const char* /*path*/, int /*runNo*/, int /*version*/, int /*subVersion*/)
104 {
105   // default method, functionality is implemented in the child class
106   return NULL;
107 }
108
109 TObject* AliHLTMisc::ExtractObject(AliCDBEntry* /*entry*/)
110 {
111   // default method, functionality is implemented in the child class
112   return NULL;
113 }
114
115 int AliHLTMisc::InitMagneticField() const
116 {
117   // default method, functionality is implemented in the child class
118   return -EFAULT;
119 }
120
121 AliHLTUInt64_t AliHLTMisc::GetTriggerMask(AliRawReader* /*rawReader*/) const
122 {
123   // default method, functionality is implemented in the child class
124   return 0;
125 }
126
127 Double_t AliHLTMisc::GetBz()
128 {
129   // default method, functionality is implemented in the child class
130   return 0.0;
131 }
132
133 Double_t AliHLTMisc::GetBz(const Double_t */*r*/)
134 {
135   // default method, functionality is implemented in the child class
136   return 0.0;
137 }
138
139 void AliHLTMisc::GetBxByBz(const Double_t r[3], Double_t b[3])
140 {
141   // default method, functionality is implemented in the child class
142   if (!r || !b) return;
143   return;
144 }
145
146 const TClass* AliHLTMisc::IsAliESDHLTDecision() const
147 {
148   // default method, functionality is implemented in the child class
149   return NULL;
150 }
151
152 int AliHLTMisc::Copy(const AliHLTGlobalTriggerDecision* /*pDecision*/, TObject* /*pESDHLTDecision*/) const
153 {
154   // default method, functionality is implemented in the child class
155   return -EFAULT;
156 }
157
158 ostream  &operator<<(ostream &out, const AliHLTComponentDataType &dt)
159 {
160   // printout of AliHLTComponentDataType struct
161   char id[kAliHLTComponentDataTypefIDsize+1];
162   strncpy(id, dt.fID, kAliHLTComponentDataTypefIDsize);
163   id[kAliHLTComponentDataTypefIDsize]=0;
164   char origin[kAliHLTComponentDataTypefOriginSize+1];
165   strncpy(origin, dt.fOrigin, kAliHLTComponentDataTypefOriginSize);
166   origin[kAliHLTComponentDataTypefOriginSize]=0;
167   out << "{" << id << ":" << origin << "}";
168   return out;
169 }