]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/html/AliHLTComponentHandler_8cxx-source.html
9025bfa2e2910668768b9e87b86f0dcb17702013
[u/mrichter/AliRoot.git] / HLT / PHOS / html / AliHLTComponentHandler_8cxx-source.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>AliHLTPHOS: /home/perthi/cern/aliroot/AliRoot_head020507/HLT/BASE/AliHLTComponentHandler.cxx Source File</title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
5 </head><body>
6 <!-- Generated by Doxygen 1.3.9.1 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div>
8 <div class="nav">
9 <a class="el" href="dir_000000.html">BASE</a></div>
10 <h1>AliHLTComponentHandler.cxx</h1><a href="AliHLTComponentHandler_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">// $Id$</span>
11 00002 
12 00003 <span class="comment">/**************************************************************************</span>
13 00004 <span class="comment"> * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *</span>
14 00005 <span class="comment"> *                                                                        *</span>
15 00006 <span class="comment"> * Authors: Matthias Richter &lt;Matthias.Richter@ift.uib.no&gt;                *</span>
16 00007 <span class="comment"> *          Timm Steinbeck &lt;timm@kip.uni-heidelberg.de&gt;                   *</span>
17 00008 <span class="comment"> *          for The ALICE Off-line Project.                               *</span>
18 00009 <span class="comment"> *                                                                        *</span>
19 00010 <span class="comment"> * Permission to use, copy, modify and distribute this software and its   *</span>
20 00011 <span class="comment"> * documentation strictly for non-commercial purposes is hereby granted   *</span>
21 00012 <span class="comment"> * without fee, provided that the above copyright notice appears in all   *</span>
22 00013 <span class="comment"> * copies and that both the copyright notice and this permission notice   *</span>
23 00014 <span class="comment"> * appear in the supporting documentation. The authors make no claims     *</span>
24 00015 <span class="comment"> * about the suitability of this software for any purpose. It is          *</span>
25 00016 <span class="comment"> * provided "as is" without express or implied warranty.                  *</span>
26 00017 <span class="comment"> **************************************************************************/</span>
27 00018 
28 00024 <span class="preprocessor">#if __GNUC__&gt;= 3</span>
29 00025 <span class="preprocessor"></span><span class="keyword">using</span> <span class="keyword">namespace </span>std;
30 00026 <span class="preprocessor">#endif</span>
31 00027 <span class="preprocessor"></span><span class="comment">//#undef HAVE_DLFCN_H</span>
32 00028 <span class="preprocessor">#ifdef HAVE_DLFCN_H</span>
33 00029 <span class="preprocessor"></span><span class="preprocessor">#include &lt;dlfcn.h&gt;</span>
34 00030 <span class="preprocessor">#else</span>
35 00031 <span class="preprocessor"></span><span class="comment">//#include &lt;Riostream.h&gt;</span>
36 00032 <span class="preprocessor">#include &lt;TSystem.h&gt;</span>
37 00033 <span class="preprocessor">#endif //HAVE_DLFCN_H</span>
38 00034 <span class="preprocessor"></span><span class="comment">//#include "AliHLTStdIncludes.h"</span>
39 00035 <span class="preprocessor">#include "<a class="code" href="AliHLTComponentHandler_8h.html">AliHLTComponentHandler.h</a>"</span>
40 00036 <span class="preprocessor">#include "<a class="code" href="AliHLTComponent_8h.html">AliHLTComponent.h</a>"</span>
41 00037 <span class="preprocessor">#include "<a class="code" href="AliHLTDataTypes_8h.html">AliHLTDataTypes.h</a>"</span>
42 00038 <span class="comment">//#include "AliHLTSystem.h"</span>
43 00039 <span class="preprocessor">#include "TString.h"</span>
44 00040 
45 00041 <span class="comment">// the standard components</span>
46 00042 <span class="comment">// #include "AliHLTFilePublisher.h"</span>
47 00043 <span class="comment">// #include "AliHLTFileWriter.h"</span>
48 00044 <span class="comment">// #include "AliHLTRootFilePublisherComponent.h"</span>
49 00045 <span class="comment">// #include "AliHLTRootFileWriterComponent.h"</span>
50 00046 
51 <a name="l00048"></a><a class="code" href="AliHLTComponentHandler_8cxx.html#a0">00048</a> <a class="code" href="AliHLTPHOSRawAnalyzerPeakFinder_8cxx.html#a0">ClassImp</a>(<a class="code" href="classAliHLTComponentHandler.html">AliHLTComponentHandler</a>)
52 00049 
53 00050 <a class="code" href="classAliHLTComponentHandler.html">AliHLTComponentHandler</a>::<a class="code" href="classAliHLTComponentHandler.html">AliHLTComponentHandler</a>()
54 00051   :
55 00052   fComponentList(),
56 00053   fScheduleList(),
57 00054   fLibraryList(),
58 00055   fEnvironment(),
59 00056   fStandardList()
60 00057 {
61 00058   <span class="comment">// see header file for class documentation</span>
62 00059   <span class="comment">// or</span>
63 00060   <span class="comment">// refer to README to build package</span>
64 00061   <span class="comment">// or</span>
65 00062   <span class="comment">// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt</span>
66 00063   memset(&amp;fEnvironment, 0, <span class="keyword">sizeof</span>(<a class="code" href="structAliHLTComponentEnvironment.html">AliHLTComponentEnvironment</a>));
67 00064   AddStandardComponents();
68 00065 }
69 00066 
70 <a name="l00067"></a><a class="code" href="classAliHLTComponentHandler.html#a1">00067</a> <a class="code" href="classAliHLTComponentHandler.html#a0">AliHLTComponentHandler::AliHLTComponentHandler</a>(<a class="code" href="structAliHLTComponentEnvironment.html">AliHLTComponentEnvironment</a>* pEnv)
71 00068   :
72 00069   fComponentList(),
73 00070   fScheduleList(),
74 00071   fLibraryList(),
75 00072   fEnvironment(),
76 00073   fStandardList()
77 00074 {
78 00075   <span class="comment">// see header file for class documentation</span>
79 00076   <span class="keywordflow">if</span> (pEnv) {
80 00077     memcpy(&amp;<a class="code" href="classAliHLTComponentHandler.html#r3">fEnvironment</a>, pEnv, <span class="keyword">sizeof</span>(<a class="code" href="structAliHLTComponentEnvironment.html">AliHLTComponentEnvironment</a>));
81 00078     <span class="keywordflow">if</span> (pEnv-&gt;<a class="code" href="structAliHLTComponentEnvironment.html#o4">fLoggingFunc</a>) {
82 00079       <span class="comment">// the AliHLTLogging::Init method also sets the stream output</span>
83 00080       <span class="comment">// and notification handler to AliLog. This should only be done</span>
84 00081       <span class="comment">// if the logging environment contains a logging function</span>
85 00082       <span class="comment">// for redirection</span>
86 00083       <a class="code" href="classAliHLTLogging.html#e0">AliHLTLogging::Init</a>(pEnv-&gt;<a class="code" href="structAliHLTComponentEnvironment.html#o4">fLoggingFunc</a>);
87 00084     }
88 00085   }  <span class="keywordflow">else</span>
89 00086     memset(&amp;<a class="code" href="classAliHLTComponentHandler.html#r3">fEnvironment</a>, 0, <span class="keyword">sizeof</span>(<a class="code" href="structAliHLTComponentEnvironment.html">AliHLTComponentEnvironment</a>));
90 00087   <a class="code" href="classAliHLTComponentHandler.html#a13">AddStandardComponents</a>();
91 00088 }
92 00089 
93 <a name="l00090"></a><a class="code" href="classAliHLTComponentHandler.html#a2">00090</a> <a class="code" href="classAliHLTComponentHandler.html#a0">AliHLTComponentHandler::AliHLTComponentHandler</a>(<span class="keyword">const</span> <a class="code" href="classAliHLTComponentHandler.html">AliHLTComponentHandler</a>&amp;)
94 00091   :
95 00092   fComponentList(),
96 00093   fScheduleList(),
97 00094   fLibraryList(),
98 00095   fEnvironment(),
99 00096   fStandardList()
100 00097 {
101 00098   <span class="comment">// see header file for class documentation</span>
102 00099   <a class="code" href="AliHLTLogging_8h.html#a7">HLTFatal</a>(<span class="stringliteral">"copy constructor untested"</span>);
103 00100 }
104 00101 
105 <a name="l00102"></a><a class="code" href="classAliHLTComponentHandler.html#a3">00102</a> <a class="code" href="classAliHLTComponentHandler.html">AliHLTComponentHandler</a>&amp; <a class="code" href="classAliHLTComponentHandler.html#a3">AliHLTComponentHandler::operator=</a>(<span class="keyword">const</span> <a class="code" href="classAliHLTComponentHandler.html">AliHLTComponentHandler</a>&amp;)
106 00103 { 
107 00104   <span class="comment">// see header file for class documentation</span>
108 00105   <a class="code" href="AliHLTLogging_8h.html#a7">HLTFatal</a>(<span class="stringliteral">"assignment operator untested"</span>);
109 00106   <span class="keywordflow">return</span> *<span class="keyword">this</span>;
110 00107 }
111 00108 
112 <a name="l00109"></a><a class="code" href="classAliHLTComponentHandler.html#a4">00109</a> <a class="code" href="classAliHLTComponentHandler.html#a4">AliHLTComponentHandler::~AliHLTComponentHandler</a>()
113 00110 {
114 00111   <span class="comment">// see header file for class documentation</span>
115 00112   <a class="code" href="classAliHLTComponentHandler.html#a14">DeleteStandardComponents</a>();
116 00113   <a class="code" href="classAliHLTComponentHandler.html#d3">UnloadLibraries</a>();
117 00114 }
118 00115 
119 <a name="l00116"></a><a class="code" href="classAliHLTComponentHandler.html#a18">00116</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a18">AliHLTComponentHandler::AnnounceVersion</a>()
120 00117 {
121 00118   <span class="comment">// see header file for class documentation</span>
122 00119   <span class="keywordtype">int</span> iResult=0;
123 00120 <span class="preprocessor">#ifdef PACKAGE_STRING</span>
124 00121 <span class="preprocessor"></span>  <span class="keywordtype">void</span> HLTbaseCompileInfo( <span class="keywordtype">char</span>*&amp; date, <span class="keywordtype">char</span>*&amp; time);
125 00122   <span class="keywordtype">char</span>* date=<span class="stringliteral">""</span>;
126 00123   <span class="keywordtype">char</span>* time=<span class="stringliteral">""</span>;
127 00124   HLTbaseCompileInfo(date, time);
128 00125   <span class="keywordflow">if</span> (!date) date=<span class="stringliteral">"unknown"</span>;
129 00126   <span class="keywordflow">if</span> (!time) time=<span class="stringliteral">"unknown"</span>;
130 00127   <a class="code" href="AliHLTLogging_8h.html#a4">HLTInfo</a>(<span class="stringliteral">"%s build on %s (%s)"</span>, PACKAGE_STRING, date, time);
131 00128 <span class="preprocessor">#else</span>
132 00129 <span class="preprocessor"></span>  <a class="code" href="AliHLTLogging_8h.html#a4">HLTInfo</a>(<span class="stringliteral">"ALICE High Level Trigger build on %s (%s) (embedded AliRoot build)"</span>, __DATE__, __TIME__);
133 00130 <span class="preprocessor">#endif</span>
134 00131 <span class="preprocessor"></span>  <span class="keywordflow">return</span> iResult;
135 00132 }
136 00133 
137 <a name="l00134"></a><a class="code" href="classAliHLTComponentHandler.html#a10">00134</a> Int_t <a class="code" href="classAliHLTComponentHandler.html#a10">AliHLTComponentHandler::RegisterComponent</a>(<a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>* pSample)
138 00135 {
139 00136   <span class="comment">// see header file for class documentation</span>
140 00137   Int_t iResult=0;
141 00138   <span class="keywordflow">if</span> (pSample) {
142 00139     <span class="keywordflow">if</span> (<a class="code" href="classAliHLTComponentHandler.html#d1">FindComponent</a>(pSample-&gt;<a class="code" href="classAliHLTComponent.html#a9">GetComponentID</a>())==NULL) {
143 00140       iResult=<a class="code" href="classAliHLTComponentHandler.html#d2">InsertComponent</a>(pSample);
144 00141       <span class="keywordflow">if</span> (iResult&gt;=0) {
145 00142         <a class="code" href="AliHLTLogging_8h.html#a4">HLTInfo</a>(<span class="stringliteral">"component %s registered"</span>, pSample-&gt;<a class="code" href="classAliHLTComponent.html#a9">GetComponentID</a>());
146 00143       }
147 00144     } <span class="keywordflow">else</span> {
148 00145       <span class="comment">// component already registered</span>
149 00146       <a class="code" href="AliHLTLogging_8h.html#a3">HLTDebug</a>(<span class="stringliteral">"component %s already registered, skipped"</span>, pSample-&gt;<a class="code" href="classAliHLTComponent.html#a9">GetComponentID</a>());
150 00147       iResult=-EEXIST;
151 00148     }
152 00149   } <span class="keywordflow">else</span> {
153 00150     iResult=-EINVAL;
154 00151   }
155 00152   <span class="keywordflow">return</span> iResult;
156 00153 }
157 00154 
158 <a name="l00155"></a><a class="code" href="classAliHLTComponentHandler.html#a12">00155</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a12">AliHLTComponentHandler::DeregisterComponent</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* componentID )
159 00156 {
160 00157   <span class="comment">// see header file for class documentation</span>
161 00158 
162 00159   <span class="keywordtype">int</span> iResult=0;
163 00160   <span class="keywordflow">if</span> (componentID) {
164 00161     <a class="code" href="AliHLTLogging_8h.html#a5">HLTWarning</a>(<span class="stringliteral">"not yet implemented, please notify the developers if you need this function"</span>);
165 00162   } <span class="keywordflow">else</span> {
166 00163     iResult=-EINVAL;
167 00164   }
168 00165   <span class="keywordflow">return</span> iResult;
169 00166 }
170 00167 
171 <a name="l00168"></a><a class="code" href="classAliHLTComponentHandler.html#a9">00168</a> Int_t <a class="code" href="classAliHLTComponentHandler.html#a9">AliHLTComponentHandler::ScheduleRegister</a>(<a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>* pSample)
172 00169 {
173 00170   <span class="comment">// see header file for class documentation</span>
174 00171   Int_t iResult=0;
175 00172   <span class="keywordflow">if</span> (pSample) {
176 00173     <a class="code" href="classAliHLTComponentHandler.html#r1">fScheduleList</a>.push_back(pSample);
177 00174   } <span class="keywordflow">else</span> {
178 00175     iResult=-EINVAL;
179 00176   }
180 00177   <span class="keywordflow">return</span> iResult;
181 00178 }
182 00179 
183 <a name="l00180"></a><a class="code" href="classAliHLTComponentHandler.html#a15">00180</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a15">AliHLTComponentHandler::CreateComponent</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* componentID, <span class="keywordtype">void</span>* pEnvParam, <span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>** argv, <a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>*&amp; component )
184 00181 {
185 00182   <span class="comment">// see header file for class documentation</span>
186 00183   <span class="keywordtype">int</span> iResult=0;
187 00184   <span class="keywordflow">if</span> (componentID) {
188 00185     <a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>* pSample=<a class="code" href="classAliHLTComponentHandler.html#d1">FindComponent</a>(componentID);
189 00186     <span class="keywordflow">if</span> (pSample!=NULL) {
190 00187       component=pSample-&gt;<a class="code" href="classAliHLTComponent.html#a13">Spawn</a>();
191 00188       <span class="keywordflow">if</span> (component) {
192 00189         <a class="code" href="AliHLTLogging_8h.html#a3">HLTDebug</a>(<span class="stringliteral">"component \"%s\" created (%p)"</span>, componentID, component);
193 00190         <span class="keywordflow">if</span> ((iResult=component-&gt;<a class="code" href="classAliHLTComponent.html#a4">Init</a>(&amp;<a class="code" href="classAliHLTComponentHandler.html#r3">fEnvironment</a>, pEnvParam, argc, argv))!=0) {
194 00191           <a class="code" href="AliHLTLogging_8h.html#a6">HLTError</a>(<span class="stringliteral">"Initialization of component \"%s\" failed with error %d"</span>, componentID, iResult);
195 00192           <span class="keyword">delete</span> component;
196 00193           component=NULL;
197 00194         }
198 00195       } <span class="keywordflow">else</span> {
199 00196         <a class="code" href="AliHLTLogging_8h.html#a6">HLTError</a>(<span class="stringliteral">"can not spawn component \"%s\""</span>, componentID);
200 00197         iResult=-ENOENT;
201 00198       }
202 00199     } <span class="keywordflow">else</span> {
203 00200       <a class="code" href="AliHLTLogging_8h.html#a5">HLTWarning</a>(<span class="stringliteral">"can not find component \"%s\""</span>, componentID);
204 00201       iResult=-ENOENT;
205 00202     }
206 00203   } <span class="keywordflow">else</span> {
207 00204     iResult=-EINVAL;
208 00205   }
209 00206   <span class="keywordflow">return</span> iResult;
210 00207 }
211 00208 
212 <a name="l00209"></a><a class="code" href="classAliHLTComponentHandler.html#d0">00209</a> Int_t <a class="code" href="classAliHLTComponentHandler.html#d0">AliHLTComponentHandler::FindComponentIndex</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* componentID)
213 00210 {
214 00211   <span class="comment">// see header file for class documentation</span>
215 00212   Int_t iResult=0;
216 00213   <span class="keywordflow">if</span> (componentID) {
217 00214     vector&lt;AliHLTComponent*&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.begin();
218 00215     <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.end() &amp;&amp; iResult&gt;=0) {
219 00216       <span class="keywordflow">if</span> (strcmp(componentID, (*element)-&gt;GetComponentID())==0) {
220 00217         <span class="keywordflow">break</span>;
221 00218       }
222 00219       element++;
223 00220       iResult++;
224 00221     }
225 00222     <span class="keywordflow">if</span> (element==<a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.end()) iResult=-ENOENT;
226 00223   } <span class="keywordflow">else</span> {
227 00224     iResult=-EINVAL;
228 00225   }
229 00226   <span class="keywordflow">return</span> iResult;
230 00227 }
231 00228 
232 <a name="l00229"></a><a class="code" href="classAliHLTComponentHandler.html#d1">00229</a> <a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>* <a class="code" href="classAliHLTComponentHandler.html#d1">AliHLTComponentHandler::FindComponent</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* componentID)
233 00230 {
234 00231   <span class="comment">// see header file for class documentation</span>
235 00232   <a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>* pSample=NULL;
236 00233   Int_t index=<a class="code" href="classAliHLTComponentHandler.html#d0">FindComponentIndex</a>(componentID);
237 00234   <span class="keywordflow">if</span> (index&gt;=0) {
238 00235     pSample=(<a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>*)<a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.at(index);
239 00236   }
240 00237   <span class="keywordflow">return</span> pSample;
241 00238 }
242 00239 
243 <a name="l00240"></a><a class="code" href="classAliHLTComponentHandler.html#d2">00240</a> Int_t <a class="code" href="classAliHLTComponentHandler.html#d2">AliHLTComponentHandler::InsertComponent</a>(<a class="code" href="classAliHLTComponent.html">AliHLTComponent</a>* pSample)
244 00241 {
245 00242   <span class="comment">// see header file for class documentation</span>
246 00243   Int_t iResult=0;
247 00244   <span class="keywordflow">if</span> (pSample!=NULL) {
248 00245     <a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.push_back(pSample);
249 00246   } <span class="keywordflow">else</span> {
250 00247     iResult=-EINVAL;
251 00248   }
252 00249   <span class="keywordflow">return</span> iResult;
253 00250 }
254 00251 
255 <a name="l00252"></a><a class="code" href="classAliHLTComponentHandler.html#a17">00252</a> <span class="keywordtype">void</span> <a class="code" href="classAliHLTComponentHandler.html#a17">AliHLTComponentHandler::List</a>() 
256 00253 {
257 00254   <span class="comment">// see header file for class documentation</span>
258 00255   vector&lt;AliHLTComponent*&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.begin();
259 00256   <span class="keywordtype">int</span> index=0;
260 00257   <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r0">fComponentList</a>.end()) {
261 00258     <a class="code" href="AliHLTLogging_8h.html#a4">HLTInfo</a>(<span class="stringliteral">"%d. %s"</span>, index++, (*element++)-&gt;GetComponentID());
262 00259   }
263 00260 }
264 00261 
265 <a name="l00262"></a><a class="code" href="classAliHLTComponentHandler.html#a5">00262</a> <span class="keywordtype">void</span> <a class="code" href="classAliHLTComponentHandler.html#a5">AliHLTComponentHandler::SetEnvironment</a>(<a class="code" href="structAliHLTComponentEnvironment.html">AliHLTComponentEnvironment</a>* pEnv) 
266 00263 {
267 00264   <span class="comment">// see header file for class documentation</span>
268 00265   <span class="keywordflow">if</span> (pEnv) {
269 00266     memcpy(&amp;<a class="code" href="classAliHLTComponentHandler.html#r3">fEnvironment</a>, pEnv, <span class="keyword">sizeof</span>(<a class="code" href="structAliHLTComponentEnvironment.html">AliHLTComponentEnvironment</a>));
270 00267     <span class="keywordflow">if</span> (<a class="code" href="classAliHLTComponentHandler.html#r3">fEnvironment</a>.<a class="code" href="structAliHLTComponentEnvironment.html#o4">fLoggingFunc</a>) {
271 00268       <span class="comment">// the AliHLTLogging::Init method also sets the stream output</span>
272 00269       <span class="comment">// and notification handler to AliLog. This should only be done</span>
273 00270       <span class="comment">// if the logging environment contains a logging function</span>
274 00271       <span class="comment">// for redirection</span>
275 00272       <a class="code" href="classAliHLTLogging.html#e0">AliHLTLogging::Init</a>(<a class="code" href="classAliHLTComponentHandler.html#r3">fEnvironment</a>.<a class="code" href="structAliHLTComponentEnvironment.html#o4">fLoggingFunc</a>);
276 00273     }
277 00274   }
278 00275 }
279 00276 
280 <a name="l00277"></a><a class="code" href="classAliHLTComponentHandler.html#a6">00277</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a6">AliHLTComponentHandler::LoadLibrary</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* libraryPath )
281 00278 {
282 00279   <span class="comment">// see header file for class documentation</span>
283 00280   <span class="keywordtype">int</span> iResult=0;
284 00281   <span class="keywordflow">if</span> (libraryPath) {
285 00282     <a class="code" href="classAliHLTComponent.html#e0">AliHLTComponent::SetGlobalComponentHandler</a>(<span class="keyword">this</span>);
286 00283     <a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html">AliHLTLibHandle</a> hLib;
287 00284     <span class="keyword">const</span> <span class="keywordtype">char</span>* loadtype=<span class="stringliteral">""</span>;
288 00285 <span class="preprocessor">#ifdef HAVE_DLFCN_H</span>
289 00286 <span class="preprocessor"></span>    <span class="comment">// use interface to the dynamic linking loader</span>
290 00287     hLib.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>=dlopen(libraryPath, RTLD_NOW);
291 00288     loadtype=<span class="stringliteral">"dlopen"</span>;
292 00289 <span class="preprocessor">#else</span>
293 00290 <span class="preprocessor"></span>    <span class="comment">// use ROOT dynamic loader</span>
294 00291     <span class="comment">// check if the library was already loaded, as Load returns</span>
295 00292     <span class="comment">// 'failure' if the library was already loaded</span>
296 00293     <a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html">AliHLTLibHandle</a>* pLib=<a class="code" href="classAliHLTComponentHandler.html#d4">FindLibrary</a>(libraryPath);
297 00294     <span class="keywordflow">if</span> (pLib) {
298 00295         <span class="keywordtype">int</span>* pRootHandle=reinterpret_cast&lt;int*&gt;(pLib-&gt;<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>);
299 00296         (*pRootHandle)++;
300 00297         <a class="code" href="AliHLTLogging_8h.html#a3">HLTDebug</a>(<span class="stringliteral">"instance %d of library %s loaded"</span>, (*pRootHandle), libraryPath);
301 00298         hLib.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>=pRootHandle;
302 00299     }
303 00300     
304 00301     <span class="keywordflow">if</span> (hLib.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>==NULL &amp;&amp; gSystem-&gt;Load(libraryPath)==0) {
305 00302       <span class="keywordtype">int</span>* pRootHandle=<span class="keyword">new</span> int;
306 00303       <span class="keywordflow">if</span> (pRootHandle) *pRootHandle=1;
307 00304       hLib.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>=pRootHandle;
308 00305       <span class="comment">//HLTDebug("library %s loaded via gSystem", libraryPath);</span>
309 00306     }
310 00307     loadtype=<span class="stringliteral">"gSystem"</span>;
311 00308 <span class="preprocessor">#endif //HAVE_DLFCN_H</span>
312 00309 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (hLib.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>!=NULL) {
313 00310       <span class="comment">// create TString object to store library path and use pointer as handle </span>
314 00311       hLib.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o1">fName</a>=<span class="keyword">new</span> TString(libraryPath);
315 00312       <a class="code" href="AliHLTLogging_8h.html#a4">HLTInfo</a>(<span class="stringliteral">"library %s loaded (%s)"</span>, libraryPath, loadtype);
316 00313       <a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.insert(<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.begin(), hLib);
317 00314       iResult=<a class="code" href="classAliHLTComponentHandler.html#a11">RegisterScheduledComponents</a>();
318 00315     } <span class="keywordflow">else</span> {
319 00316       <a class="code" href="AliHLTLogging_8h.html#a6">HLTError</a>(<span class="stringliteral">"can not load library %s"</span>, libraryPath);
320 00317 <span class="preprocessor">#ifdef HAVE_DLFCN_H</span>
321 00318 <span class="preprocessor"></span>      <a class="code" href="AliHLTLogging_8h.html#a6">HLTError</a>(<span class="stringliteral">"dlopen error: %s"</span>, dlerror());
322 00319 <span class="preprocessor">#endif //HAVE_DLFCN_H</span>
323 00320 <span class="preprocessor"></span><span class="preprocessor">#ifdef __APPLE__</span>
324 00321 <span class="preprocessor"></span>      iResult=-EFTYPE;
325 00322 <span class="preprocessor">#else</span>
326 00323 <span class="preprocessor"></span>      iResult=-ELIBACC;
327 00324 <span class="preprocessor">#endif</span>
328 00325 <span class="preprocessor"></span>    }
329 00326     <a class="code" href="classAliHLTComponent.html#e1">AliHLTComponent::UnsetGlobalComponentHandler</a>();
330 00327   } <span class="keywordflow">else</span> {
331 00328     iResult=-EINVAL;
332 00329   }
333 00330   <span class="keywordflow">return</span> iResult;
334 00331 }
335 00332 
336 <a name="l00333"></a><a class="code" href="classAliHLTComponentHandler.html#a8">00333</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a8">AliHLTComponentHandler::UnloadLibrary</a>( <span class="keyword">const</span> <span class="keywordtype">char</span>* libraryPath )
337 00334 {
338 00335   <span class="comment">// see header file for class documentation</span>
339 00336   <span class="keywordtype">int</span> iResult=0;
340 00337   <span class="keywordflow">if</span> (libraryPath) {
341 00338     vector&lt;AliHLTLibHandle&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.begin();
342 00339     <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.end()) {
343 00340       TString* pName=reinterpret_cast&lt;TString*&gt;((*element).fName);
344 00341       <span class="keywordflow">if</span> (pName-&gt;CompareTo(libraryPath)==0) {
345 00342         <a class="code" href="classAliHLTComponentHandler.html#a8">UnloadLibrary</a>(*element);
346 00343         <a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.erase(element);
347 00344         <span class="keywordflow">break</span>;
348 00345       }
349 00346       element++;
350 00347   }
351 00348   } <span class="keywordflow">else</span> {
352 00349     iResult=-EINVAL;
353 00350   }
354 00351   <span class="keywordflow">return</span> iResult;
355 00352 }
356 00353 
357 <a name="l00354"></a><a class="code" href="classAliHLTComponentHandler.html#d5">00354</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a8">AliHLTComponentHandler::UnloadLibrary</a>(<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html">AliHLTComponentHandler::AliHLTLibHandle</a> &amp;handle)
358 00355 {
359 00356   <span class="comment">// see header file for class documentation</span>
360 00357   <span class="keywordtype">int</span> iResult=0;
361 00358   fgAliLoggingFunc=NULL;
362 00359   TString* pName=reinterpret_cast&lt;TString*&gt;(handle.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o1">fName</a>);
363 00360 <span class="preprocessor">#ifdef HAVE_DLFCN_H</span>
364 00361 <span class="preprocessor"></span>  dlclose(handle.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>);
365 00362 <span class="preprocessor">#else</span>
366 00363 <span class="preprocessor"></span>  <span class="keywordtype">int</span>* pCount=reinterpret_cast&lt;int*&gt;(handle.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>);
367 00364   <span class="keywordflow">if</span> (--(*pCount)==0) {
368 00365     <span class="keywordflow">if</span> (pName) {
369 00384     }
370 00385     <span class="keywordflow">else</span> {
371 00386       <a class="code" href="AliHLTLogging_8h.html#a6">HLTError</a>(<span class="stringliteral">"missing library name, can not unload"</span>);
372 00387     }
373 00388     <span class="keyword">delete</span> pCount;
374 00389   }
375 00390 <span class="preprocessor">#endif //HAVE_DLFCN_H</span>
376 00391 <span class="preprocessor"></span>  handle.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o1">fName</a>=NULL;
377 00392   handle.<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>=NULL;
378 00393   <span class="keywordflow">if</span> (pName) {
379 00394     <a class="code" href="AliHLTLogging_8h.html#a3">HLTDebug</a>(<span class="stringliteral">"unload library %s"</span>, pName-&gt;Data());
380 00395     <span class="keyword">delete</span> pName;
381 00396   } <span class="keywordflow">else</span> {
382 00397     <a class="code" href="AliHLTLogging_8h.html#a5">HLTWarning</a>(<span class="stringliteral">"missing name for unloaded library"</span>);
383 00398   }
384 00399   pName=NULL;
385 00400   <span class="keywordflow">return</span> iResult;
386 00401 }
387 00402 
388 <a name="l00403"></a><a class="code" href="classAliHLTComponentHandler.html#d3">00403</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#d3">AliHLTComponentHandler::UnloadLibraries</a>()
389 00404 {
390 00405   <span class="comment">// see header file for class documentation</span>
391 00406   <span class="keywordtype">int</span> iResult=0;
392 00407   vector&lt;AliHLTLibHandle&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.begin();
393 00408   <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.end()) {
394 00409     <a class="code" href="classAliHLTComponentHandler.html#a8">UnloadLibrary</a>(*element);
395 00410     <a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.erase(element);
396 00411     element=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.begin();
397 00412   }
398 00413   <span class="keywordflow">return</span> iResult;
399 00414 }
400 00415 
401 <a name="l00416"></a><a class="code" href="classAliHLTComponentHandler.html#a7">00416</a> <span class="keywordtype">void</span>* <a class="code" href="classAliHLTComponentHandler.html#a7">AliHLTComponentHandler::FindSymbol</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* library, <span class="keyword">const</span> <span class="keywordtype">char</span>* symbol)
402 00417 {
403 00418   <span class="comment">// see header file for class documentation</span>
404 00419   <a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html">AliHLTLibHandle</a>* hLib=<a class="code" href="classAliHLTComponentHandler.html#d4">FindLibrary</a>(library);
405 00420   <span class="keywordflow">if</span> (hLib==NULL) <span class="keywordflow">return</span> NULL;
406 00421   <span class="keywordtype">void</span>* pFunc=NULL;
407 00422 <span class="preprocessor">#ifdef HAVE_DLFCN_H</span>
408 00423 <span class="preprocessor"></span>  pFunc=dlsym(hLib-&gt;<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o0">fHandle</a>, symbol);
409 00424 <span class="preprocessor">#else</span>
410 00425 <span class="preprocessor"></span>  TString* name=reinterpret_cast&lt;TString*&gt;(hLib-&gt;<a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html#o1">fName</a>);
411 00426   pFunc=gSystem-&gt;DynFindSymbol(name-&gt;Data(), symbol);
412 00427 <span class="preprocessor">#endif</span>
413 00428 <span class="preprocessor"></span>  <span class="keywordflow">return</span> pFunc;
414 00429 }
415 00430 
416 <a name="l00431"></a><a class="code" href="classAliHLTComponentHandler.html#d4">00431</a> <a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html">AliHLTComponentHandler::AliHLTLibHandle</a>* <a class="code" href="classAliHLTComponentHandler.html#d4">AliHLTComponentHandler::FindLibrary</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* library)
417 00432 {
418 00433   <span class="comment">// see header file for class documentation</span>
419 00434   <a class="code" href="structAliHLTComponentHandler_1_1AliHLTLibHandle.html">AliHLTLibHandle</a>* hLib=NULL;
420 00435   vector&lt;AliHLTLibHandle&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.begin();
421 00436   <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r2">fLibraryList</a>.end()) {
422 00437     TString* name=reinterpret_cast&lt;TString*&gt;((*element).fName);
423 00438     <span class="keywordflow">if</span> (name-&gt;CompareTo(library)==0) {
424 00439       hLib=&amp;(*element);
425 00440       <span class="keywordflow">break</span>;
426 00441     }
427 00442     element++;
428 00443   }
429 00444   <span class="keywordflow">return</span> hLib;
430 00445 }
431 00446 
432 <a name="l00447"></a><a class="code" href="classAliHLTComponentHandler.html#a13">00447</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a13">AliHLTComponentHandler::AddStandardComponents</a>()
433 00448 {
434 00449   <span class="comment">// see header file for class documentation</span>
435 00450   <span class="keywordtype">int</span> iResult=0;
436 00451   <a class="code" href="classAliHLTComponent.html#e0">AliHLTComponent::SetGlobalComponentHandler</a>(<span class="keyword">this</span>);
437 00452 <span class="comment">//   fStandardList.push_back(new AliHLTFilePublisher);</span>
438 00453 <span class="comment">//   fStandardList.push_back(new AliHLTFileWriter);</span>
439 00454 <span class="comment">//   fStandardList.push_back(new AliHLTRootFilePublisherComponent);</span>
440 00455 <span class="comment">//   fStandardList.push_back(new AliHLTRootFileWriterComponent);</span>
441 00456   <a class="code" href="classAliHLTComponent.html#e1">AliHLTComponent::UnsetGlobalComponentHandler</a>();
442 00457   iResult=<a class="code" href="classAliHLTComponentHandler.html#a11">RegisterScheduledComponents</a>();
443 00458   <span class="keywordflow">return</span> iResult;
444 00459 }
445 00460 
446 <a name="l00461"></a><a class="code" href="classAliHLTComponentHandler.html#a11">00461</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a11">AliHLTComponentHandler::RegisterScheduledComponents</a>()
447 00462 {
448 00463   <span class="comment">// see header file for class documentation</span>
449 00464   <span class="keywordtype">int</span> iResult=0;
450 00465   vector&lt;AliHLTComponent*&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r1">fScheduleList</a>.begin();
451 00466   <span class="keywordtype">int</span> iLocalResult=0;
452 00467   <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r1">fScheduleList</a>.end()) {
453 00468     iLocalResult=<a class="code" href="classAliHLTComponentHandler.html#a10">RegisterComponent</a>(*element);
454 00469     <span class="keywordflow">if</span> (iResult==0) iResult=iLocalResult;
455 00470     <a class="code" href="classAliHLTComponentHandler.html#r1">fScheduleList</a>.erase(element);
456 00471     element=<a class="code" href="classAliHLTComponentHandler.html#r1">fScheduleList</a>.begin();
457 00472   }
458 00473   <span class="keywordflow">return</span> iResult;
459 00474 }
460 00475 
461 <a name="l00476"></a><a class="code" href="classAliHLTComponentHandler.html#a14">00476</a> <span class="keywordtype">int</span> <a class="code" href="classAliHLTComponentHandler.html#a14">AliHLTComponentHandler::DeleteStandardComponents</a>()
462 00477 {
463 00478   <span class="comment">// see header file for class documentation</span>
464 00479   <span class="keywordtype">int</span> iResult=0;
465 00480   vector&lt;AliHLTComponent*&gt;::iterator element=<a class="code" href="classAliHLTComponentHandler.html#r4">fStandardList</a>.begin();
466 00481   <span class="keywordflow">while</span> (element!=<a class="code" href="classAliHLTComponentHandler.html#r4">fStandardList</a>.end()) {
467 00482     <span class="comment">//DeregisterComponent((*element)-&gt;GetComponentID());</span>
468 00483     <span class="keyword">delete</span>(*element);
469 00484     <a class="code" href="classAliHLTComponentHandler.html#r4">fStandardList</a>.erase(element);
470 00485     element=<a class="code" href="classAliHLTComponentHandler.html#r4">fStandardList</a>.begin();
471 00486   }
472 00487   <span class="keywordflow">return</span> iResult;
473 00488 }
474 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 4 04:49:52 2007 for AliHLTPHOS by&nbsp;
475 <a href="http://www.doxygen.org/index.html">
476 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
477 </body>
478 </html>