001
002
003 #ifndef GAUDIALG_GAUDICOMMONIMP_H
004 #define GAUDIALG_GAUDICOMMONIMP_H 1
005
006
007
008
009
010 #include "GaudiAlg/GetData.h"
011 #include "GaudiAlg/GaudiCommon.h"
012
013
014
015
016
017
018
019
020
021
022
023 template < class PBASE >
024 inline const std::string
025 GaudiCommon<PBASE>::fullTESLocation( const std::string & location,
026 const bool useRootInTES ) const
027 {
028
029
030
031
032
033
034
035
036
037
038 return ( !useRootInTES || rootInTES().empty() ?
039 location
040 :
041 location.empty() || ( location == "/Event" ) ?
042 rootInTES().substr(0,rootInTES().size()-1)
043 :
044 0 == location.find("/Event/") ?
045 rootInTES() + location.substr(7)
046 :
047 rootInTES() + location );
048 }
049
050
051
052 template < class PBASE >
053 template < class TYPE >
054 inline typename Gaudi::Utils::GetData<TYPE>::return_type
055 GaudiCommon<PBASE>::get( IDataProviderSvc* service ,
056 const std::string& location,
057 const bool useRootInTES ) const
058 {
059
060 Assert( 0 != service , "get():: IDataProvider* points to NULL!" ) ;
061
062 Gaudi::Utils::GetData<TYPE> helper ;
063 return helper ( *this , service ,
064 fullTESLocation ( location , useRootInTES ) ) ;
065 }
066
067
068
069 template < class PBASE >
070 template < class TYPE >
071 inline bool GaudiCommon<PBASE>::exist( IDataProviderSvc* service ,
072 const std::string& location ,
073 const bool useRootInTES ) const
074 {
075
076 Assert( 0 != service , "exist():: IDataProvider* points to NULL!" ) ;
077
078 const std::string & fullLoc = fullTESLocation( location, useRootInTES );
079 SmartDataPtr<TYPE> obj( service , fullLoc ) ;
080 return obj ? true : false ;
081 }
082
083
084
085
086
087
088
089 template <class PBASE>
090 template <class TYPE,class TYPE2>
091 inline TYPE* GaudiCommon<PBASE>::getOrCreate( IDataProviderSvc* svc ,
092 const std::string& location ,
093 const bool useRootInTES ) const
094 {
095
096 Assert( 0 != svc , "getOrCreate():: svc points to NULL!" ) ;
097 const std::string & fullLoc = fullTESLocation( location, useRootInTES );
098 SmartDataPtr<TYPE> obj ( svc , fullLoc ) ;
099 if ( !obj )
100 {
101 TYPE2* o = new TYPE2() ;
102 put ( svc , o , location ) ;
103 return o ;
104 }
105 TYPE* aux = obj ;
106 if( !aux )
107 { Exception ( "getOrCreate():: No valid data at '" + fullLoc + "'" ) ; }
108
109 return aux ;
110 }
111
112
113
114
115
116 template < class PBASE >
117 template < class TOOL >
118 inline TOOL* GaudiCommon<PBASE>::tool( const std::string& type ,
119 const std::string& name ,
120 const IInterface* parent ,
121 bool create ) const
122 {
123 TOOL* Tool = 0 ;
124
125 if ( name.empty() )
126 {
127 Tool = tool<TOOL>( type , parent , create ) ;
128 }
129 else
130 {
131 Assert( 0 != this->toolSvc() , "tool():: IToolSvc* points to NULL!" ) ;
132
133 const StatusCode sc =
134 this->toolSvc()->retrieveTool ( type , name , Tool , parent , create ) ;
135 if ( sc.isFailure() )
136 { Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'", sc ) ; }
137 if ( 0 == Tool )
138 { Exception("tool():: Could not retrieve Tool '" + type + "'/'" + name + "'" ) ; }
139
140 addToToolList( Tool );
141 }
142
143 return Tool ;
144 }
145
146
147
148
149
150 template < class PBASE >
151 template < class TOOL >
152 inline TOOL* GaudiCommon<PBASE>::tool( const std::string& type ,
153 const IInterface* parent ,
154 bool create ) const
155 {
156
157 Assert ( 0 != PBASE::toolSvc() , "IToolSvc* points to NULL!" );
158
159 TOOL* Tool = 0 ;
160 const StatusCode sc =
161 this->toolSvc() -> retrieveTool ( type, Tool, parent , create );
162 if ( sc.isFailure() )
163 { Exception("tool():: Could not retrieve Tool '" + type + "'", sc ) ; }
164 if ( 0 == Tool )
165 { Exception("tool():: Could not retrieve Tool '" + type + "'" ) ; }
166
167 addToToolList( Tool );
168
169 return Tool ;
170 }
171
172
173
174
175
176 template < class PBASE >
177 template < class SERVICE >
178 inline SERVICE* GaudiCommon<PBASE>::svc( const std::string& name ,
179 const bool create ) const
180 {
181 SERVICE* s = 0 ;
182 Assert ( 0 != this->svcLoc() , "ISvcLocator* points to NULL!" );
183
184 StatusCode sc = this->svcLoc() -> service( name , s , create ) ;
185
186 if ( sc.isFailure() )
187 { Exception ( "svc():: Could not retrieve Svc '" + name + "'", sc ) ; }
188 if ( 0 == s )
189 { Exception ( "svc():: Could not retrieve Svc '" + name + "'" ) ; }
190
191 addToServiceList( s, name ) ;
192
193 return s ;
194 }
195
196
197
198
199
200 template <class PBASE>
201 inline IUpdateManagerSvc *
202 GaudiCommon<PBASE>::updMgrSvc() const
203 {
204 if ( !m_updMgrSvc )
205 { m_updMgrSvc = svc<IUpdateManagerSvc>("UpdateManagerSvc",true); }
206 return m_updMgrSvc ;
207 }
208
209
210
211
212
213 template <class PBASE>
214 inline IDataProviderSvc *
215 GaudiCommon<PBASE>::fastContainersSvc() const
216 {
217 if ( !m_fastContainersSvc )
218 { m_fastContainersSvc = svc<IDataProviderSvc>("FastContainersSvc",true); }
219 return m_fastContainersSvc ;
220 }
221
222
223
224
225 template < class PBASE >
226 template < class T >
227 inline TransientFastContainer<T> *
228 GaudiCommon<PBASE>::getFastContainer( const std::string &location,
229 typename TransientFastContainer<T>::size_type initial )
230 {
231 typedef TransientFastContainer<T> container_type;
232
233 IDataProviderSvc* svc = fastContainersSvc();
234 Assert( 0 != svc , "getFastContainer(): cannot get FastContainersSvc" );
235
236 container_type *ptr = NULL;
237 SmartDataPtr<container_type> obj( svc, location );
238 if (!obj){
239 ptr = new container_type(initial);
240 StatusCode status = svc->registerObject(location,ptr);
241 if ( !status.isSuccess() ){
242 Exception("getFastContainer(): cannot register '" +
243 System::typeinfoName( typeid( *ptr ) ) +
244 "' at address '" + location + "'" , status );
245 }
246 } else {
247 ptr = obj;
248 if ( !ptr ){
249 Exception("getFastContainer(): No valid container at '" + location + "'");
250 }
251 }
252
253 return ptr;
254 }
255
256
257
258
259
260 template <class PBASE>
261 inline MsgStream&
262 GaudiCommon<PBASE>::msgStream ( const MSG::Level level ) const
263 {
264 if ( !m_msgStream )
265 { m_msgStream = new MsgStream ( PBASE::msgSvc() , this->name() ) ; }
266 return *m_msgStream << level ;
267 }
268
269
270
271
272
273 template <class PBASE>
274 inline StatusCode GaudiCommon<PBASE>::Assert( const bool OK ,
275 const std::string& msg ,
276 const StatusCode sc ) const
277 {
278 return ( OK ? StatusCode(StatusCode::SUCCESS, true) : Exception( msg , sc ) ) ;
279 }
280
281
282
283
284
285 template <class PBASE>
286 inline void GaudiCommon<PBASE>::resetMsgStream() const
287 {
288 if ( 0 != m_msgStream ) { delete m_msgStream; m_msgStream = 0; }
289 }
290
291
292
293
294
295 template <class PBASE>
296 inline StatusCode
297 GaudiCommon<PBASE>::Assert( const bool OK ,
298 const char* msg ,
299 const StatusCode sc ) const
300 {
301 return OK ? StatusCode(StatusCode::SUCCESS, true) : Exception( msg , sc ) ;
302 }
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320 #define ALG_ERROR( message , code ) \
321 ( Error( message + \
322 std::string ( " [ at line " ) + \
323 GaudiAlg::fileLine ( __LINE__ ) + \
324 std::string ( " in file '" ) + \
325 std::string ( __FILE__ ) + "']" , code ) )
326
327
328
329 #endif
330
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|