| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

TsDataSvc.cpp
Go to the documentation of this file.
1 //====================================================================
2 // TsDataSvc.cpp
3 //--------------------------------------------------------------------
4 //
5 // Package : System ( The LHCb Offline System)
6 //
7 // Description: implementation of the Transient data service: TsDataSvc
8 //
9 // Author : M.Frank
10 // History :
11 // +---------+----------------------------------------------+---------
12 // | Date | Comment | Who
13 // +---------+----------------------------------------------+---------
14 // | 29/10/98| Initial version | M.Frank
15 // | 20/2/99 | Automatic data preloading introduced. | M.Frank
16 // | 25/4/13 | Locking for concurrent access introduced. | D.Piparo
17 // +---------+----------------------------------------------+---------
18 //
19 //====================================================================
20 #define TSDATASVC_DATASVC_CPP
21
22 // Framework include files
23 #include "GaudiKernel/IConversionSvc.h"
24 #include "GaudiKernel/IConverter.h"
25 #include "GaudiKernel/IOpaqueAddress.h"
26
27 #include "GaudiKernel/DataObject.h"
28 #include "GaudiKernel/GaudiException.h"
29 #include "GaudiKernel/SvcFactory.h"
30 #include "GaudiKernel/xtoa.h"
31
32 #include "GaudiKernel/DataIncident.h"
33 #include "GaudiKernel/IIncidentSvc.h"
34 #include "GaudiKernel/RegistryEntry.h"
35 #include "GaudiKernel/TsDataSvc.h"
36
37 // Include files
38 #include <algorithm>
39 #include <cassert>
40 #include <cstdlib>
41 #include <mutex>
42 #include <sstream>
43 #include <vector>
44
45 // Macro to lock a scope
46 #define STD_LOCK_GUARD_MACRO std::lock_guard<tsDataSvcMutex> lock( m_accessMutex );
47
48 namespace
49 {
52 std::string itemToPath( int item ) { return '/' + std::to_string( item ); }
53
54 std::string operator+( char c, boost::string_ref sr )
55 {
56 std::string s{{c}};
57 s.append( sr.data(), sr.size() );
58 return s;
59 }
60
61 boost::string_ref::size_type find( boost::string_ref s, char c, size_t o )
62 {
63 if ( !s.empty() ) s.remove_prefix( o );
64 auto r = s.find( c );
65 return r == boost::string_ref::npos ? r : ( r + o );
66 }
67
68 std::string to_string( boost::string_ref sr ) { return {sr.data(), sr.size()}; }
69 }
70
71 // If you absolutely need optimization: switch off dynamic_cast.
72 // This improves access to the data store roughly by 10 %
73 // for balanced trees.
74 //
75 // M.Frank
76 #define CAST_REGENTRY( x, y ) dynamic_cast<x>( y )
77 //#define CAST_REGENTRY(x,y) (x)(y)
78 typedef DataSvcHelpers::RegistryEntry RegEntry;
79
80 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
81 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
82
83 #define DEBMSG ON_DEBUG debug()
84 #define VERMSG ON_VERBOSE verbose()
85
89 StatusCode TsDataSvc::clearSubTree( boost::string_ref sub_tree_path )
90 {
91 DataObject* pObject = nullptr;
92 StatusCode status = findObject( sub_tree_path, pObject );
93 if ( !status.isSuccess() ) return status;
94 RegEntry* node_entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
95 if ( !node_entry ) return INVALID_OBJECT;
96 RegEntry* parent = node_entry->parentEntry();
97 if ( !parent ) return INVALID_PARENT;
98 parent->remove( node_entry );
99 return StatusCode::SUCCESS;
100 }
101
105 StatusCode TsDataSvc::clearSubTree( DataObject* pObject )
106 {
107 if ( !checkRoot() ) return INVALID_ROOT;
108 RegEntry* entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
109 if ( !entry ) return INVALID_OBJECT;
110 RegEntry* parent = entry->parentEntry();
111 if ( !parent ) return INVALID_PARENT;
112 parent->remove( entry );
113 return SUCCESS;
114 }
115
117 StatusCode TsDataSvc::clearStore()
118 {
119 if ( !checkRoot() ) return INVALID_ROOT;
120 m_root->release();
121 m_root = nullptr;
122 return SUCCESS;
123 }
124
128 StatusCode TsDataSvc::traverseSubTree( boost::string_ref sub_tree_path, IDataStoreAgent* pAgent )
129 {
130 STD_LOCK_GUARD_MACRO
131 DataObject* pO = nullptr;
132 StatusCode status = findObject( sub_tree_path, pO );
133 return status.isSuccess() ? traverseSubTree( pO, pAgent ) : status;
134 }
135
137 StatusCode TsDataSvc::traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent )
138 {
139 STD_LOCK_GUARD_MACRO
140 if ( !checkRoot() ) return INVALID_ROOT;
141 RegEntry* entry = CAST_REGENTRY( RegEntry*, pObject->registry() );
142 if ( !entry ) return INVALID_OBJECT;
143 return entry->traverseTree( pAgent );
144 }
145
147 StatusCode TsDataSvc::traverseTree( IDataStoreAgent* pAgent )
148 {
149 STD_LOCK_GUARD_MACRO
150 if ( !checkRoot() ) return INVALID_ROOT;
151 return m_root->traverseTree( pAgent );
152 }
153
158 StatusCode TsDataSvc::setRoot( std::string root_path, DataObject* pRootObj )
159 {
160 clearStore().ignore();
161 return i_setRoot( std::move( root_path ), pRootObj );
162 }
163
169 StatusCode TsDataSvc::i_setRoot( std::string root_path, DataObject* pRootObj )
170 {
171 if ( pRootObj ) {
172 m_root = new RegEntry( std::move( root_path ) );
173 m_root->makeHard( pRootObj );
174 m_root->setDataSvc( this );
175 // No done with GaudiHive. preLoad().ignore();
176 }
177 return SUCCESS;
178 }
179
184 StatusCode TsDataSvc::setRoot( std::string root_path, IOpaqueAddress* pRootAddr )
185 {
186 clearStore().ignore();
187 return i_setRoot( std::move( root_path ), pRootAddr );
188 }
189
195 StatusCode TsDataSvc::i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr )
196 {
197 if ( pRootAddr ) {
198 m_root = new RegEntry( std::move( root_path ) );
199 m_root->makeHard( pRootAddr );
200 m_root->setDataSvc( this );
201 // Not done with GaudiHive. preLoad().ignore();
202 }
203 return SUCCESS;
204 }
205
207 StatusCode TsDataSvc::setDataLoader( IConversionSvc* pDataLoader, IDataProviderSvc* dpsvc )
208 {
209 if ( pDataLoader ) pDataLoader->addRef();
210 if ( m_dataLoader ) m_dataLoader->release();
211 if ( pDataLoader ) {
212 pDataLoader->setDataProvider( dpsvc == nullptr ? this : dpsvc ).ignore();
213 }
214 m_dataLoader = pDataLoader;
215 return SUCCESS;
216 }
217
219 StatusCode TsDataSvc::objectParent( const DataObject* pObject, IRegistry*& refpParent )
220 {
221 STD_LOCK_GUARD_MACRO
222 if ( !pObject ) return INVALID_OBJECT;
223 return objectParent( pObject->registry(), refpParent );
224 }
226 StatusCode TsDataSvc::objectParent( const IRegistry* pRegistry, IRegistry*& refpParent )
227 {
228 STD_LOCK_GUARD_MACRO
229 if ( !checkRoot() ) return INVALID_ROOT;
230 const RegEntry* node_entry = CAST_REGENTRY( const RegEntry*, pRegistry );
231 if ( !node_entry ) return INVALID_OBJECT;
232 refpParent = node_entry->parent();
233 return StatusCode::SUCCESS;
234 }
235
237 StatusCode TsDataSvc::objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& leaves )
238 {
239 STD_LOCK_GUARD_MACRO
240 if ( !pObject ) return INVALID_OBJECT;
241 return objectLeaves( pObject->registry(), leaves );
242 }
243
247 StatusCode TsDataSvc::objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& leaves )
248 {
249 STD_LOCK_GUARD_MACRO
250 if ( !checkRoot() ) return INVALID_ROOT;
251 const RegEntry* node_entry = CAST_REGENTRY( const RegEntry*, pRegistry );
252 if ( !node_entry ) return INVALID_OBJECT;
253 leaves.insert( leaves.end(), node_entry->leaves().begin(), node_entry->leaves().end() );
254 // leaves = node_entry->leaves();
255 return StatusCode::SUCCESS;
256 }
257
259 StatusCode TsDataSvc::registerAddress( boost::string_ref fullPath, IOpaqueAddress* pAddress )
260 {
261 if ( fullPath.empty() ) return INVALID_OBJ_PATH;
262 if ( fullPath.front() != SEPARATOR ) {
263 return registerAddress( m_root, fullPath, pAddress );
264 }
265 IRegistry* pRegistry = nullptr;
266 return registerAddress( pRegistry, fullPath, pAddress );
267 }
268
270 StatusCode TsDataSvc::registerAddress( DataObject* parentObj, boost::string_ref objectPath, IOpaqueAddress* pAddress )
271 {
272 IRegistry* pRegistry = ( parentObj ? parentObj->registry() : nullptr );
273 return registerAddress( pRegistry, objectPath, pAddress );
274 }
275
277 StatusCode TsDataSvc::registerAddress( IRegistry* parentObj, boost::string_ref objPath, IOpaqueAddress* pAddress )
278 {
279 if ( !checkRoot() ) return INVALID_ROOT;
280 if ( objPath.empty() ) return INVALID_OBJ_PATH;
281 if ( !parentObj ) {
282 if ( objPath.front() != SEPARATOR ) {
283 return registerAddress( m_root, objPath, pAddress );
284 }
285 auto sep = find( objPath, SEPARATOR, 1 );
286 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) != m_rootName.value() ) {
287 return INVALID_PARENT;
288 }
289 return registerAddress( m_root, objPath.substr( sep ), pAddress );
290 }
291 if ( objPath.front() != SEPARATOR ) {
292 return registerAddress( parentObj, SEPARATOR + objPath, pAddress );
293 }
294 RegEntry* par_entry = CAST_REGENTRY( RegEntry*, parentObj );
295 if ( !par_entry ) return INVALID_PARENT;
296 auto sep = objPath.rfind( SEPARATOR );
297 if ( sep > 0 && sep != boost::string_ref::npos ) {
298 auto p_path = objPath.substr( 0, sep );
299 auto o_path = objPath.substr( sep );
300 RegEntry* p_entry = par_entry->findLeaf( p_path );
301 // Create default object leafs if the
302 // intermediate nodes are not present
303 if ( !p_entry && m_forceLeaves ) {
304 DataObject* pLeaf = createDefaultObject();
305 StatusCode sc = registerObject( par_entry->identifier(), p_path, pLeaf );
306 if ( !sc.isSuccess() ) delete pLeaf;
307 p_entry = par_entry->findLeaf( p_path );
308 }
309 if ( !p_entry ) return INVALID_PARENT;
310 return registerAddress( p_entry, o_path, pAddress );
311 }
312 StatusCode status = par_entry->add( to_string( objPath ), pAddress );
313 return status.isSuccess() ? status : DOUBL_OBJ_PATH;
314 }
315
317 StatusCode TsDataSvc::unregisterAddress( boost::string_ref fullPath )
318 {
319 if ( fullPath.empty() ) return INVALID_OBJ_PATH;
320 IRegistry* pRegistry = nullptr;
321 if ( fullPath.front() != SEPARATOR ) {
322 return unregisterAddress( m_root, fullPath );
323 }
324 return unregisterAddress( pRegistry, fullPath );
325 }
326
328 StatusCode TsDataSvc::unregisterAddress( DataObject* pParent, boost::string_ref objPath )
329 {
330 IRegistry* pRegistry = ( pParent ? pParent->registry() : nullptr );
331 return unregisterAddress( pRegistry, objPath );
332 }
333
335 StatusCode TsDataSvc::unregisterAddress( IRegistry* pParent, boost::string_ref objPath )
336 {
337 if ( !checkRoot() ) return INVALID_ROOT;
338
339 if ( objPath.empty() ) return INVALID_OBJ_PATH;
340 if ( !pParent ) {
341 if ( objPath.front() != SEPARATOR ) {
342 return unregisterAddress( m_root, objPath );
343 }
344 auto sep = find( objPath, SEPARATOR, 1 );
345 if ( sep == boost::string_ref::npos || objPath.substr( 0, sep ) != m_rootName.value() ) {
346 return INVALID_PARENT;
347 }
348 return unregisterAddress( m_root, objPath.substr( sep ) );
349 }
350 if ( objPath.front() != SEPARATOR ) {
351 return unregisterAddress( pParent, SEPARATOR + objPath );
352 }
353 RegEntry* node_entry = CAST_REGENTRY( RegEntry*, pParent );
354 if ( node_entry ) {
355 RegEntry* leaf_entry = node_entry->findLeaf( objPath );
356 if ( leaf_entry ) {
357 auto sep = objPath.rfind( SEPARATOR );
358 if ( sep > 0 && sep != boost::string_ref::npos ) {
359 return unregisterAddress( leaf_entry->parent(), objPath.substr( sep ) );
360 }
361 StatusCode status = node_entry->remove( objPath );
362 if ( status.isSuccess() ) return status;
363 }
364 }
365 return INVALID_PARENT;
366 }
367
369 StatusCode TsDataSvc::registerObject( boost::string_ref fullPath, DataObject* pObject )
370 {
371 return registerObject( nullptr, fullPath, pObject );
372 }
373
375 StatusCode TsDataSvc::registerObject( boost::string_ref parentPath, boost::string_ref objPath, DataObject* pObject )
376 {
377 DataObject* pO = nullptr;
378 StatusCode status = retrieveObject( parentPath, pO );
379 if ( !status.isSuccess() && m_forceLeaves ) {
380 pO = createDefaultObject();
381 status = registerObject( parentPath, pO );
382 if ( !status.isSuccess() ) pO->release();
383 }
384 return status.isSuccess() ? registerObject( pO, objPath, pObject ) : status;
385 }
386
388 StatusCode TsDataSvc::registerObject( boost::string_ref parentPath, int item, DataObject* pObject )
389 {
390 return registerObject( parentPath, itemToPath( item ), pObject );
391 }
392
394 StatusCode TsDataSvc::registerObject( DataObject* parentObj, int item, DataObject* pObject )
395 {
396 return registerObject( parentObj, itemToPath( item ), pObject );
397 }
398
400 StatusCode TsDataSvc::registerObject( DataObject* parentObj, boost::string_ref objPath, DataObject* pObject )
401 {
402 if ( !checkRoot() ) return INVALID_ROOT;
403 if ( !parentObj ) {
404 if ( !objPath.empty() ) {
405 if ( objPath.front() != SEPARATOR ) {
406 return registerObject( m_rootName.value(), objPath, pObject );
407 }
408 auto sep = find( objPath, SEPARATOR, 1 );
409 if ( sep != boost::string_ref::npos ) {
410 return registerObject( objPath.substr( 0, sep ), objPath.substr( sep ), pObject );
411 }
412 }
413 return INVALID_OBJ_PATH;
414 }
415 RegEntry* node_entry = CAST_REGENTRY( RegEntry*, parentObj->registry() );
416 if ( node_entry ) {
417 StatusCode status = INVALID_PARENT;
418 auto sep = find( objPath, SEPARATOR, 1 );
419 if ( sep != boost::string_ref::npos ) {
420 auto p_path = objPath.substr( 0, sep );
421 auto o_path = objPath.substr( sep );
422 RegEntry* par_entry = node_entry->findLeaf( p_path );
423 // Create default object leafs if the
424 // intermediate nodes are not present
425 if ( !par_entry && m_forceLeaves ) {
426 DataObject* pLeaf = createDefaultObject();
427 StatusCode sc = registerObject( parentObj, p_path, pLeaf );
428 if ( !sc.isSuccess() ) delete pLeaf;
429 par_entry = node_entry->findLeaf( p_path );
430 } else if ( par_entry && !par_entry->object() ) {
431 status = retrieveEntry( node_entry, p_path, par_entry );
432 if ( !status.isSuccess() && !par_entry->address() && m_forceLeaves ) {
433 DataObject* pLeaf = createDefaultObject();
434 StatusCode sc = registerObject( parentObj, p_path, pLeaf );
435 if ( !sc.isSuccess() ) delete pLeaf;
436 par_entry = node_entry->findLeaf( p_path );
437 }
438 }
439 node_entry = par_entry;
440 if ( node_entry ) {
441 DataObject* obj = node_entry->object();
442 if ( obj ) status = registerObject( obj, o_path, pObject );
443 }
444 } else {
445 RegEntry* leaf = node_entry->findLeaf( objPath );
446 if ( !leaf ) {
447 status = node_entry->add( to_string( objPath ), pObject );
448 } else {
449 DataObject* obj = leaf->object();
450 if ( !obj ) {
451 if ( !pObject ) {
452 error() << "registerObject: trying to register null DataObject" << endmsg;
453 return StatusCode::FAILURE;
454 } else {
455 pObject->setRegistry( leaf );
456 }
457 leaf->setAddress( nullptr );
458 leaf->setObject( pObject );
459 status = StatusCode::SUCCESS;
460 } else {
461 status = DOUBL_OBJ_PATH;
462 }
463 }
464 }
465 return status;
466 }
467 return INVALID_PARENT;
468 }
469
471 StatusCode TsDataSvc::unregisterObject( boost::string_ref fullPath )
472 {
473 DataObject* pObject = nullptr;
474 StatusCode status = findObject( fullPath, pObject );
475 if ( status.isFailure() ) return status;
476 RegEntry* pEntry = CAST_REGENTRY( RegEntry*, pObject->registry() );
477 if ( !pEntry ) return INVALID_ROOT;
478 if ( !pEntry->isEmpty() ) return DIR_NOT_EMPTY;
479 RegEntry* pParent = pEntry->parentEntry();
480 if ( !pParent ) return INVALID_PARENT;
481 if ( pObject ) pObject->addRef();
482 pParent->remove( pEntry );
483 return StatusCode::SUCCESS;
484 }
485
487 StatusCode TsDataSvc::unregisterObject( boost::string_ref parentPath, boost::string_ref objPath )
488 {
489 DataObject* pO = nullptr;
490 StatusCode status = findObject( parentPath, pO );
491 return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
492 }
493
495 StatusCode TsDataSvc::unregisterObject( boost::string_ref parentPath, int item )
496 {
497 return unregisterObject( parentPath, itemToPath( item ) );
498 }
499
501 StatusCode TsDataSvc::unregisterObject( DataObject* pObject )
502 {
503 if ( !checkRoot() ) return INVALID_ROOT;
504 RegEntry* entry = m_root->findLeaf( pObject );
505 if ( !entry ) return INVALID_OBJECT;
506 RegEntry* parent = entry->parentEntry();
507 if ( !parent ) return INVALID_PARENT;
508 if ( !entry->isEmpty() ) return DIR_NOT_EMPTY;
509 if ( entry->object() ) entry->object()->addRef();
510 if ( parent ) parent->remove( entry );
511 return SUCCESS;
512 }
513
515 StatusCode TsDataSvc::unregisterObject( DataObject* pParentObj, boost::string_ref objectPath )
516 {
517 if ( !checkRoot() ) return INVALID_ROOT;
518 try {
519 RegEntry* parent = CAST_REGENTRY( RegEntry*, pParentObj->registry() );
520 if ( parent ) {
521 RegEntry* entry = parent->findLeaf( objectPath );
522 if ( !entry ) return INVALID_OBJECT;
523 if ( !entry->isEmpty() ) return DIR_NOT_EMPTY;
524 if ( entry->object() ) entry->object()->addRef();
525 parent->remove( entry );
526 return SUCCESS;
527 }
528 } catch ( ... ) {
529 }
530 return INVALID_PARENT;
531 }
532
534 StatusCode TsDataSvc::unregisterObject( DataObject* pParentObj, int item )
535 {
536 return unregisterObject( pParentObj, itemToPath( item ) );
537 }
538
541 DataObject* TsDataSvc::handleDataFault( IRegistry* pReg, boost::string_ref path )
542 {
543 if ( m_enableFaultHdlr ) {
544 IRegistry* pLeaf = nullptr;
545 if ( pReg && path.empty() ) {
546 DataIncident incident( name(), m_faultName, pReg->identifier() );
547 m_incidentSvc->fireIncident( incident );
548 return pReg->object();
549 } else if ( pReg ) {
550 std::string p = pReg->identifier();
551 if ( path.front() != SEPARATOR ) p += SEPARATOR;
552 p.append( path.data(), path.size() );
553 DataIncident incident( name(), m_faultName, p );
554 m_incidentSvc->fireIncident( incident );
555 pLeaf = m_root->findLeaf( p );
556 } else {
557 std::string p = m_root->identifier();
558 if ( path.front() != SEPARATOR ) p += SEPARATOR;
559 p.append( path.data(), path.size() );
560 DataIncident incident( name(), m_faultName, p );
561 m_incidentSvc->fireIncident( incident );
562 pLeaf = m_root->findLeaf( p );
563 }
564 if ( pLeaf ) return pLeaf->object();
565 }
566 return nullptr;
567 }
568
572 StatusCode TsDataSvc::loadObject( IRegistry* pRegistry )
573 {
574 IConversionSvc* pLoader = getDataLoader( pRegistry );
575 return loadObject( pLoader, pRegistry );
576 }
577
581 StatusCode TsDataSvc::loadObject( IConversionSvc* pLoader, IRegistry* pRegistry )
582 {
583 STD_LOCK_GUARD_MACRO
584 StatusCode status = INVALID_OBJ_ADDR;
585 DataObject* pObject = nullptr;
586 if ( !pLoader ) { // Precondition: Data loader must be present
587 if ( handleDataFault( pRegistry ) )
588 return SUCCESS;
589 else
590 return NO_DATA_LOADER;
591 }
592 if ( !pRegistry ) { // Precondition: Directory must be valid
593 if ( handleDataFault( pRegistry ) )
594 return SUCCESS;
595 else
596 return INVALID_OBJ_ADDR;
597 }
598
599 VERMSG << "Requested object " << pRegistry->identifier() << endmsg;
600
601 if ( m_enableAccessHdlr ) {
602 // Fire data access incident
603 DataIncident incident( name(), m_accessName, pRegistry->identifier() );
604 m_incidentSvc->fireIncident( incident );
605 }
606 if ( !m_inhibitPathes.empty() ) {
607 const auto& ident = pRegistry->identifier();
608 auto inhibit = std::find( m_inhibitPathes.begin(), m_inhibitPathes.end(), ident );
609 if ( inhibit != m_inhibitPathes.end() ) return NO_ACCESS;
610 }
611 IOpaqueAddress* pAddress = pRegistry->address();
612 if ( !pAddress ) { // Precondition:
613 return INVALID_OBJ_ADDR; // Address must be valid
614 }
615 try {
616 status = pLoader->createObj( pAddress, pObject ); // Call data loader
617 if ( status.isSuccess() ) {
618
619 VERMSG << "Object " << pRegistry->identifier() << " created" << endmsg;
620
621 RegEntry* pEntry = CAST_REGENTRY( RegEntry*, pRegistry );
622 pEntry->setObject( pObject );
623
624 VERMSG << "Filling object " << pRegistry->identifier() << endmsg;
625 status = pLoader->fillObjRefs( pAddress, pObject );
626 }
627 } catch ( const GaudiException& exc ) {
628 if ( handleDataFault( pRegistry ) ) return SUCCESS;
629 throw GaudiException( "GaudiException in loadObject() " + pRegistry->identifier(), name(), StatusCode::FAILURE,
630 exc );
631 } catch ( const std::exception& x ) {
632 if ( handleDataFault( pRegistry ) ) return SUCCESS;
633 throw GaudiException( "std::exception in loadObject() " + pRegistry->identifier() + ": " +
634 System::typeinfoName( typeid( x ) ) + ", " + x.what(),
635 name(), StatusCode::FAILURE );
636 } catch ( ... ) {
637 if ( handleDataFault( pRegistry ) ) return SUCCESS;
638 throw GaudiException( "UNKN exception in loadObject() " + pRegistry->identifier(), name(), StatusCode::FAILURE );
639 }
640 if ( !status.isSuccess() ) {
641 if ( handleDataFault( pRegistry ) ) return StatusCode::SUCCESS;
642 }
643 ON_VERBOSE if ( status.isSuccess() )
644 {
645 verbose() << "Object " << pRegistry->identifier() << " successfully loaded" << endmsg;
646 }
647 return status;
648 }
649
651 StatusCode TsDataSvc::retrieveEntry( RegEntry* parentObj, boost::string_ref path, RegEntry*& pEntry )
652 {
653 STD_LOCK_GUARD_MACRO
654 auto sep = find( path, SEPARATOR, 1 );
655 StatusCode status = StatusCode( INVALID_ROOT, true );
656 pEntry = nullptr;
657 // A.Valassi 16.08.2001 avoid core dump if store is empty
658 if ( checkRoot() ) {
659 if ( !parentObj ) {
660 if ( path.empty() || path == m_rootName ) return retrieveEntry( m_root, "", pEntry );
661 if ( path.front() != SEPARATOR ) return retrieveEntry( m_root, path, pEntry );
662 if ( sep == boost::string_ref::npos ) return INVALID_OBJ_PATH;
663 if ( !m_root->object() ) {
664 RegEntry* r = nullptr;
665 status = retrieveEntry( m_root, "", r );
666 if ( !status.isSuccess() ) return status;
667 }
668 return retrieveEntry( m_root, path.substr( sep ), pEntry );
669 }
670 if ( sep != boost::string_ref::npos ) { // the string contains a separator (after pos 0)
671 auto p_path = path.substr( 0, sep );
672 auto o_path = path.substr( sep );
673 if ( !parentObj->object() ) { // if the parent object has not been loaded yet, load it now
674 status = loadObject( parentObj );
675 if ( !status.isSuccess() ) return status;
676 }
677 RegEntry* root_entry = parentObj->findLeaf( p_path );
678 if ( !root_entry && m_enableFaultHdlr ) {
679 // If not even the parent is there, an incident
680 // to load the parent must be fired...
681 handleDataFault( parentObj, p_path );
682 root_entry = parentObj->findLeaf( p_path );
683 }
684 if ( root_entry ) {
685 DataObject* pO = root_entry->object();
686 if ( !pO ) {
687 // Object is not loaded: load the object if at all possible
688 status = loadObject( root_entry );
689 if ( !status.isSuccess() ) return status;
690 }
691 if ( root_entry->isSoft() ) {
692 root_entry = CAST_REGENTRY( RegEntry*, pO->registry() );
693 }
694 return retrieveEntry( root_entry, o_path, pEntry );
695 }
696 return status;
697 } else if ( path.empty() ) {
698 pEntry = parentObj;
699 } else {
700 if ( !parentObj->object() ) { // if the parent object has not been loaded yet, load it now
701 status = loadObject( parentObj );
702 if ( !status.isSuccess() ) return status;
703 }
704 // last leave in search: find leaf and load
705 pEntry = parentObj->findLeaf( path );
706 // If no registry entry was found, trigger incident for action-on-demand
707 if ( !pEntry && m_enableFaultHdlr ) {
708 handleDataFault( parentObj, path );
709 pEntry = ( path.empty() ? parentObj : parentObj->findLeaf( path ) );
710 }
711 }
712 // Check results and return
713 if ( !pEntry ) {
714 status = INVALID_OBJ_PATH;
715 } else if ( !pEntry->object() ) {
716 status = loadObject( pEntry );
717 } else if ( m_enableAccessHdlr ) {
718 // Fire data access incident
719 // I do not know if this is a good idea....
720 // This fires too often!
721 //
722 // DataIncident incident(name(), m_accessName, pEntry->identifier());
723 // m_incidentSvc->fireIncident(incident);
724 status = SUCCESS;
725 } else {
726 status = SUCCESS;
727 }
728 }
729 return status;
730 }
731
733 StatusCode TsDataSvc::retrieveObject( IRegistry* pRegistry, boost::string_ref path, DataObject*& pObject )
734 {
735 STD_LOCK_GUARD_MACRO
736 pObject = nullptr;
737 RegEntry *result = nullptr, *parent = CAST_REGENTRY( RegEntry *, pRegistry );
738 StatusCode status = retrieveEntry( parent, path, result );
739 if ( status.isSuccess() ) pObject = result->object();
740 return status;
741 }
742
744 StatusCode TsDataSvc::retrieveObject( boost::string_ref fullPath, DataObject*& pObject )
745 {
746 IRegistry* nullDir = nullptr;
747 return retrieveObject( nullDir, fullPath, pObject );
748 }
749
751 StatusCode TsDataSvc::retrieveObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
752 {
753 DataObject* parent = nullptr;
754 StatusCode status = retrieveObject( parentPath, parent );
755 return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
756 }
757
759 StatusCode TsDataSvc::retrieveObject( boost::string_ref parentPath, int item, DataObject*& pObject )
760 {
761 return retrieveObject( parentPath, itemToPath( item ), pObject );
762 }
763
765 StatusCode TsDataSvc::retrieveObject( DataObject* parentObj, boost::string_ref path, DataObject*& pObject )
766 {
767 IRegistry* pRegistry = ( parentObj ? parentObj->registry() : nullptr );
768 return retrieveObject( pRegistry, path, pObject );
769 }
770
772 StatusCode TsDataSvc::retrieveObject( DataObject* parentObj, int item, DataObject*& pObject )
773 {
774 return retrieveObject( parentObj, itemToPath( item ), pObject );
775 }
776
778 StatusCode TsDataSvc::findObject( IRegistry* pRegistry, boost::string_ref path, DataObject*& pObject )
779 {
780 STD_LOCK_GUARD_MACRO
781 pObject = nullptr;
782 IRegistry* pReg = ( pRegistry ? pRegistry : m_root );
783 RegEntry* root_entry = CAST_REGENTRY( RegEntry*, pReg );
784 if ( root_entry ) {
785 if ( !path.empty() ) pReg = root_entry->find( path );
786 if ( !pReg ) return INVALID_OBJ_PATH;
787 pObject = pReg->object();
788 }
789 return pObject ? IDataProviderSvc_NO_ERROR : OBJ_NOT_LOADED;
790 }
791
793 StatusCode TsDataSvc::findObject( boost::string_ref path, DataObject*& pObject )
794 {
795 STD_LOCK_GUARD_MACRO
796 pObject = nullptr;
797 if ( !checkRoot() ) return INVALID_ROOT;
798 if ( path.empty() || path == m_rootName ) {
799 pObject = m_root->object();
800 return !pObject ? OBJ_NOT_LOADED : IDataProviderSvc_NO_ERROR;
801 }
802 if ( path.front() != SEPARATOR ) {
803 return findObject( m_rootName.value(), path, pObject );
804 }
805 return findObject( static_cast<IRegistry*>( nullptr ), path, pObject );
806 }
807
809 StatusCode TsDataSvc::findObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
810 {
811 DataObject* parent = nullptr;
812 StatusCode status = findObject( parentPath, parent );
813 return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
814 }
815
817 StatusCode TsDataSvc::findObject( boost::string_ref parentPath, int item, DataObject*& pObject )
818 {
819 return findObject( parentPath, itemToPath( item ), pObject );
820 }
821
823 StatusCode TsDataSvc::findObject( DataObject* parentObj, int item, DataObject*& pObject )
824 {
825 return findObject( parentObj, itemToPath( item ), pObject );
826 }
827
829 StatusCode TsDataSvc::findObject( DataObject* parentObj, boost::string_ref path, DataObject*& pObject )
830 {
831 return findObject( parentObj ? parentObj->registry() : nullptr, path, pObject );
832 }
833
835 StatusCode TsDataSvc::updateObject( boost::string_ref updatePath )
836 {
837 DataObject* pO = nullptr;
838 StatusCode status = findObject( updatePath, pO );
839 return status.isSuccess() ? updateObject( pO ) : retrieveObject( updatePath, pO );
840 }
841
843 StatusCode TsDataSvc::updateObject( IRegistry* pRegistry )
844 {
845 if ( !pRegistry ) { // Precondition:
846 return INVALID_OBJ_ADDR; // Addres must be valid
847 }
848 DataObject* toUpdate = pRegistry->object();
849 if ( !toUpdate ) { // Try first to load
850 return loadObject( pRegistry );
851 }
852 return updateObject( toUpdate );
853 }
854
856 StatusCode TsDataSvc::updateObject( DataObject* toUpdate )
857 {
858 STD_LOCK_GUARD_MACRO
859 StatusCode status = INVALID_OBJ_ADDR;
860 if ( !toUpdate ) { // Precondition:
861 return INVALID_OBJECT; // Address must be valid
862 }
863 IRegistry* pRegistry = toUpdate->registry(); // Precondition:
864 if ( !pRegistry ) { // Need valid registry
865 return INVALID_OBJECT;
866 }
867 IOpaqueAddress* pAddress = pRegistry->address(); // Precondition:
868 if ( !pAddress ) { // Need valid address
869 return INVALID_OBJ_ADDR;
870 }
871 IConversionSvc* pLoader = getDataLoader( pRegistry );
872 if ( !pLoader ) { // Precondition:
873 return NO_DATA_LOADER; // Data loader must be present
874 }
875 if ( !m_inhibitPathes.empty() ) {
876 auto& ident = pRegistry->identifier();
877 auto inhibit = std::find( m_inhibitPathes.begin(), m_inhibitPathes.end(), ident );
878 if ( inhibit != m_inhibitPathes.end() ) return NO_ACCESS;
879 }
880 try {
881 status = pLoader->updateObj( pAddress, toUpdate ); // Call data loader
882 if ( status.isSuccess() ) {
883 status = pLoader->updateObjRefs( pAddress, toUpdate );
884 }
885 } catch ( const GaudiException& exc ) {
886 throw GaudiException( "GaudiException in updateObject() " + pRegistry->name(), name(), StatusCode::FAILURE, exc );
887 } catch ( const std::exception& x ) {
888 throw GaudiException( "std::exception in updateObject() " + pRegistry->name() + ": " +
889 System::typeinfoName( typeid( x ) ) + ", " + x.what(),
890 name(), StatusCode::FAILURE );
891 } catch ( ... ) {
892 throw GaudiException( "UNKN exception in updateObject() " + pRegistry->name(), name(), StatusCode::FAILURE );
893 }
894 return status;
895 }
896
898 StatusCode TsDataSvc::updateObject( boost::string_ref parentPath, boost::string_ref updatePath )
899 {
900 DataObject* pParent = nullptr;
901 StatusCode status = findObject( parentPath, pParent );
902 return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
903 }
904
906 StatusCode TsDataSvc::updateObject( DataObject* parent, boost::string_ref updatePath )
907 {
908 DataObject* pObject = nullptr;
909 StatusCode status = findObject( parent, updatePath, pObject );
910 return status.isSuccess() ? updateObject( pObject ) : status;
911 }
912
913 // Link object
914 StatusCode TsDataSvc::linkObject( IRegistry* from, boost::string_ref objPath, DataObject* to )
915 {
916 STD_LOCK_GUARD_MACRO
917 if ( !checkRoot() ) return INVALID_ROOT;
918 try {
919 RegEntry* from_entry = CAST_REGENTRY( RegEntry*, from );
920 if ( from_entry ) {
921 // First check if both objects are already registered to the store
922 RegEntry* to_entry = m_root->findLeaf( to );
923 if ( !to_entry ) return INVALID_OBJECT;
924 auto sep = objPath.rfind( SEPARATOR );
925 if ( sep > 0 && sep != boost::string_ref::npos ) { // in case the objPath is a sub-directory itself
926 DataObject* pO = nullptr;
927 StatusCode sc = retrieveObject( from, objPath.substr( 0, sep ), pO );
928 return sc.isSuccess() ? linkObject( pO->registry(), objPath.substr( sep ), to ) : sc;
929 }
930 // Now register the soft link
931 StatusCode status = from_entry->add( to_string( objPath ), to, true );
932 return status.isSuccess() ? IDataProviderSvc_NO_ERROR : DOUBL_OBJ_PATH;
933 }
934 } catch ( ... ) {
935 }
936 return INVALID_PARENT;
937 }
938
940 StatusCode TsDataSvc::linkObject( boost::string_ref fullPath, DataObject* to )
941 {
942 STD_LOCK_GUARD_MACRO
943 if ( fullPath.empty() ) return INVALID_OBJ_PATH;
944 if ( fullPath.front() != SEPARATOR ) return linkObject( m_rootName.value(), fullPath, to );
945 auto sep = fullPath.rfind( SEPARATOR );
946 return linkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ), to );
947 }
948
950 StatusCode TsDataSvc::linkObject( boost::string_ref from, boost::string_ref objPath, DataObject* to )
951 {
952 STD_LOCK_GUARD_MACRO
953 DataObject* pO = nullptr;
954 StatusCode status = retrieveObject( from, pO );
955 return status.isSuccess() ? linkObject( pO->registry(), objPath, to ) : status;
956 }
957
959 StatusCode TsDataSvc::linkObject( DataObject* from, boost::string_ref objPath, DataObject* to )
960 {
961 STD_LOCK_GUARD_MACRO
962 if ( from ) {
963 IRegistry* from_entry = from->registry();
964 if ( from_entry ) return linkObject( from_entry, objPath, to );
965 }
966 return INVALID_PARENT;
967 }
968
970 StatusCode TsDataSvc::unlinkObject( IRegistry* from, boost::string_ref objPath )
971 {
972 STD_LOCK_GUARD_MACRO
973 if ( !checkRoot() ) return INVALID_ROOT;
974 try {
975 RegEntry* from_entry = CAST_REGENTRY( RegEntry*, from );
976 if ( from_entry ) {
977 auto sep = objPath.rfind( SEPARATOR );
978 if ( sep > 0 && sep != boost::string_ref::npos ) { // in case the objPath is a sub-directory itself
979 DataObject* pO = nullptr;
980 StatusCode sc = findObject( from, objPath.substr( 0, sep ), pO );
981 return sc.isSuccess() ? unlinkObject( pO->registry(), objPath.substr( sep ) ) : sc;
982 }
983 StatusCode status = from_entry->remove( objPath );
984 return status.isSuccess() ? status : INVALID_OBJ_PATH;
985 }
986 } catch ( ... ) {
987 }
988 return INVALID_PARENT;
989 }
990
992 StatusCode TsDataSvc::unlinkObject( boost::string_ref fullPath )
993 {
994 if ( fullPath.empty() ) return INVALID_OBJ_PATH;
995 if ( fullPath.front() != SEPARATOR ) {
996 return unlinkObject( m_rootName.value(), fullPath );
997 }
998 auto sep = fullPath.rfind( SEPARATOR );
999 return unlinkObject( fullPath.substr( 0, sep ), fullPath.substr( sep ) );
1000 }
1001
1003 StatusCode TsDataSvc::unlinkObject( boost::string_ref from, boost::string_ref objPath )
1004 {
1005 DataObject* pObject = nullptr;
1006 StatusCode status = findObject( from, pObject );
1007 return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
1008 }
1009
1011 StatusCode TsDataSvc::unlinkObject( DataObject* from, boost::string_ref objPath )
1012 {
1013 if ( !checkRoot() ) return INVALID_ROOT;
1014 return unlinkObject( m_root->findLeaf( from ), objPath );
1015 }
1016
1018 StatusCode TsDataSvc::addPreLoadItem( const DataStoreItem& item )
1019 {
1020 auto i = std::find( m_preLoads.begin(), m_preLoads.end(), item );
1021 if ( i == m_preLoads.end() ) m_preLoads.push_back( item );
1022 return StatusCode::SUCCESS;
1023 }
1024
1026 StatusCode TsDataSvc::addPreLoadItem( std::string itemPath )
1027 {
1028 return addPreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
1029 }
1030
1032 StatusCode TsDataSvc::removePreLoadItem( const DataStoreItem& item )
1033 {
1034 auto i = std::remove( m_preLoads.begin(), m_preLoads.end(), item );
1035 m_preLoads.erase( i, m_preLoads.end() );
1036 return StatusCode::SUCCESS;
1037 }
1038
1040 StatusCode TsDataSvc::removePreLoadItem( std::string itemPath )
1041 {
1042 return removePreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
1043 }
1044
1046 StatusCode TsDataSvc::resetPreLoad()
1047 {
1048 m_preLoads.clear();
1049 return StatusCode::SUCCESS;
1050 }
1051
1053 StatusCode TsDataSvc::preLoad( int depth, int load_depth, DataObject* pObject )
1054 {
1055 // unused: StatusCode sc = StatusCode::FAILURE;
1056 if ( pObject && depth++ < load_depth ) {
1057 RegEntry* dir = CAST_REGENTRY( RegEntry*, pObject->registry() );
1058 if ( dir ) {
1059 for ( const auto& i : *dir ) {
1060 DataObject* pObj = nullptr;
1061 StatusCode status = retrieveObject( pObject, i->name(), pObj );
1062 if ( status.isSuccess() && depth < load_depth ) {
1063 preLoad( depth, load_depth, pObj ).ignore();
1064 }
1065 }
1066 }
1067 }
1068 return StatusCode::SUCCESS;
1069 }
1070
1072 StatusCode TsDataSvc::preLoad()
1073 {
1074 DataObject* pObj = nullptr;
1075 for ( const auto& i : m_preLoads ) {
1076 StatusCode sc = retrieveObject( i.path(), pObj );
1077 int load_depth = i.depth();
1078 if ( sc.isSuccess() && load_depth > 1 ) {
1079 preLoad( 1, load_depth, pObj ).ignore();
1080 }
1081 }
1082 return StatusCode::SUCCESS;
1083 }
1084
1086 StatusCode TsDataSvc::initialize()
1087 {
1088 // Nothing to do: just call base class initialisation
1089 StatusCode sc = Service::initialize();
1090 if ( !sc.isSuccess() ) return sc;
1091 sc = service( "IncidentSvc", m_incidentSvc, true );
1092 if ( UNLIKELY( !sc.isSuccess() ) ) {
1093 error() << "Failed to access incident service." << endmsg;
1094 }
1095 return sc;
1096 }
1097
1099 StatusCode TsDataSvc::reinitialize()
1100 {
1101 StatusCode sc;
1102 // the finalize part is copied here
1103 setDataLoader( nullptr ).ignore();
1104 resetPreLoad().ignore();
1105 clearStore().ignore();
1106 if ( m_incidentSvc ) {
1107 m_incidentSvc->release();
1108 m_incidentSvc = nullptr;
1109 }
1110 // re-initialize the base class
1111 sc = Service::reinitialize();
1112 if ( UNLIKELY( !sc.isSuccess() ) ) {
1113 error() << "Unable to reinitialize base class" << endmsg;
1114 return sc;
1115 }
1116 // the initialize part is copied here
1117 sc = service( "IncidentSvc", m_incidentSvc, true );
1118 if ( UNLIKELY( !sc.isSuccess() ) ) {
1119 error() << "Failed to access incident service." << endmsg;
1120 return sc;
1121 }
1122 // return
1123 return StatusCode::SUCCESS;
1124 }
1125
1127 StatusCode TsDataSvc::finalize()
1128 {
1129 // Nothing to do: just call base class initialisation
1130 setDataLoader( nullptr ).ignore();
1131 resetPreLoad().ignore();
1132 clearStore().ignore();
1133 if ( m_incidentSvc ) {
1134 m_incidentSvc->release();
1135 m_incidentSvc = nullptr;
1136 }
1137 return Service::finalize();
1138 }
1139
1141 CLID TsDataSvc::rootCLID() const { return ( (CLID)m_rootCLID ); }
1142
1144 const std::string& TsDataSvc::rootName() const { return ( m_rootName ); }
1145
1147 DataObject* TsDataSvc::createDefaultObject() const { return new DataObject(); }
1148
1152 IConversionSvc* TsDataSvc::getDataLoader( IRegistry* /* pReg */ ) { return m_dataLoader; }
1153
1155 TsDataSvc::~TsDataSvc()
1156 {
1157 setDataLoader( nullptr ).ignore();
1158 resetPreLoad().ignore();
1159 clearStore().ignore();
1160 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
StatusCode::SUCCESS
Definition: StatusCode.h:29
Gaudi::Units::sr
constexpr double sr
Definition: SystemOfUnits.h:116
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
to_string
string to_string(const T &value)
Definition: mergesort.cpp:37
DataSvcHelpers::RegistryEntry::findLeaf
RegistryEntry * findLeaf(boost::string_ref path) const
Find identified leaf in this registry node.
Definition: RegistryEntry.h:94
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
DataSvcHelpers::RegistryEntry::object
DataObject * object() const override
Retrive object behind the link.
Definition: RegistryEntry.h:122
gaudirun.c
c
Definition: gaudirun.py:407
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
IConverter::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
SEPARATOR
constexpr char SEPARATOR
Definition: RegistryEntry.cpp:40
TsDataSvc::setRoot
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
Definition: TsDataSvc.cpp:158
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
IConversionSvc
Definition: IConversionSvc.h:37
TsDataSvc::addPreLoadItem
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
Definition: TsDataSvc.cpp:1018
TsDataSvc::linkObject
StatusCode linkObject(IRegistry *from, boost::string_ref objPath, DataObject *to) override
Add a link to another object.
Definition: TsDataSvc.cpp:914
TsDataSvc::unregisterObject
StatusCode unregisterObject(boost::string_ref fullPath) override
Unregister object from the data store.
Definition: TsDataSvc.cpp:471
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:336
DataSvcHelpers::RegistryEntry::traverseTree
virtual StatusCode traverseTree(IDataStoreAgent *pAgent, int level=0)
traverse data tree
Definition: RegistryEntry.cpp:298
TsDataSvc::traverseTree
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
Definition: TsDataSvc.cpp:147
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
TsDataSvc::updateObject
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
Definition: TsDataSvc.cpp:843
GaudiPython.Bindings.SUCCESS
SUCCESS
Definition: Bindings.py:56
TsDataSvc::unregisterAddress
StatusCode unregisterAddress(boost::string_ref fullPath) override
IDataManagerSvc: Unregister object address from the data store.
Definition: TsDataSvc.cpp:317
TsDataSvc::m_accessName
Gaudi::Property< std::string > m_accessName
Definition: TsDataSvc.h:81
TsDataSvc::m_rootCLID
Gaudi::Property< CLID > m_rootCLID
Definition: TsDataSvc.h:70
std::to_string
T to_string(T...args)
TsDataSvc::retrieveObject
StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject) override
Retrieve object from data store.
Definition: TsDataSvc.cpp:733
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
IConverter::setDataProvider
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
TsDataSvc::~TsDataSvc
~TsDataSvc() override
Standard Destructor.
Definition: TsDataSvc.cpp:1155
DataObject::setRegistry
void setRegistry(IRegistry *pRegistry)
Set pointer to Registry.
Definition: DataObject.h:71
DataSvcHelpers::RegistryEntry::release
unsigned long release() override
IInterface implementation: Reference the object.
Definition: RegistryEntry.cpp:68
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
TsDataSvc::initialize
StatusCode initialize() override
Service initialization.
Definition: TsDataSvc.cpp:1086
TsDataSvc::removePreLoadItem
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
Definition: TsDataSvc.cpp:1032
std::vector::end
T end(T...args)
TsDataSvc::getDataLoader
virtual IConversionSvc * getDataLoader(IRegistry *pReg)
Retrieve customizable data loader according to registry entry to be retrieved.
Definition: TsDataSvc.cpp:1152
DataSvcHelpers::RegistryEntry::leaves
const Store & leaves() const
Access the leaves of the object.
Definition: RegistryEntry.h:130
TsDataSvc::m_dataLoader
IConversionSvc * m_dataLoader
Pointer to data loader service.
Definition: TsDataSvc.h:66
TsDataSvc::setDataLoader
StatusCode setDataLoader(IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data pro...
Definition: TsDataSvc.cpp:207
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:46
std::remove
T remove(T...args)
DataSvcHelpers::RegistryEntry::setAddress
void setAddress(IOpaqueAddress *pAddress) override
Set/Update Opaque address.
Definition: RegistryEntry.cpp:117
DataStoreItem
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:61
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
IConverter::updateObj
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
TsDataSvc::resetPreLoad
StatusCode resetPreLoad() override
Clear the preload list.
Definition: TsDataSvc.cpp:1046
DataSvcHelpers::RegistryEntry::parentEntry
virtual RegistryEntry * parentEntry()
Pointer to parent registry entry.
Definition: RegistryEntry.h:92
std::string
STL class.
VERMSG
#define VERMSG
Definition: TsDataSvc.cpp:84
DataSvcHelpers::RegistryEntry::isSoft
virtual bool isSoft() const
Is the link soft or hard.
Definition: RegistryEntry.h:128
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
xtoa.h
SvcFactory.h
TsDataSvc::registerAddress
StatusCode registerAddress(boost::string_ref fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
Definition: TsDataSvc.cpp:259
DataObject::addRef
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:59
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
DataSvcHelpers::RegistryEntry::setObject
void setObject(DataObject *obj)
Set/Update object address.
Definition: RegistryEntry.cpp:128
TsDataSvc::preLoad
StatusCode preLoad() override
load all preload items of the list
Definition: TsDataSvc.cpp:1072
TsDataSvc::findObject
StatusCode findObject(boost::string_ref fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: TsDataSvc.cpp:793
TsDataSvc::m_incidentSvc
IIncidentSvc * m_incidentSvc
Pointer to incident service.
Definition: TsDataSvc.h:68
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
ON_VERBOSE
#define ON_VERBOSE
Definition: TsDataSvc.cpp:81
std::exception::what
T what(T...args)
IIncidentSvc.h
TsDataSvc::m_root
DataSvcHelpers::RegistryEntry * m_root
Pointer to root entry.
Definition: TsDataSvc.h:86
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException.h
std::string::append
T append(T...args)
TsDataSvc::m_preLoads
LoadItems m_preLoads
Items to be pre-loaded.
Definition: TsDataSvc.h:84
IConverter::updateObjRefs
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
RegEntry
DataSvcHelpers::RegistryEntry RegEntry
Definition: TsDataSvc.cpp:78
std::vector::erase
T erase(T...args)
DataSvcHelpers::RegistryEntry::setDataSvc
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
Definition: RegistryEntry.h:90
TsDataSvc::rootName
const std::string & rootName() const override
IDataManagerSvc: Accessor for root event name.
Definition: TsDataSvc.cpp:1144
TsDataSvc::m_enableAccessHdlr
Gaudi::Property< bool > m_enableAccessHdlr
Definition: TsDataSvc.h:79
TsDataSvc::reinitialize
StatusCode reinitialize() override
Service initialization.
Definition: TsDataSvc.cpp:1099
TsDataSvc::objectLeaves
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
Definition: TsDataSvc.cpp:237
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
TsDataSvc::unlinkObject
StatusCode unlinkObject(IRegistry *from, boost::string_ref objPath) override
Remove a link to another object.
Definition: TsDataSvc.cpp:970
DataSvcHelpers::RegistryEntry::isEmpty
virtual bool isEmpty() const
Simple check if the Container is empty.
Definition: RegistryEntry.h:134
Service::reinitialize
StatusCode reinitialize() override
Definition: Service.cpp:250
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
std::vector::clear
T clear(T...args)
DataSvcHelpers::RegistryEntry::address
IOpaqueAddress * address() const override
Retrieve opaque storage address.
Definition: RegistryEntry.h:124
std::exception
STL class.
std::move
T move(T...args)
TsDataSvc::retrieveEntry
StatusCode retrieveEntry(DataSvcHelpers::RegistryEntry *pNode, boost::string_ref path, DataSvcHelpers::RegistryEntry *&pEntry)
Retrieve registry entry from store.
Definition: TsDataSvc.cpp:651
IRegistry::object
virtual DataObject * object() const =0
Retrieve object behind the link.
IOpaqueAddress.h
RegistryEntry.h
DataSvcHelpers::RegistryEntry
Definition of an entry in the transient data store.
Definition: RegistryEntry.h:36
DataObject::release
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:51
std::vector::insert
T insert(T...args)
GaudiPython.Bindings.DataObject
DataObject
Definition: Bindings.py:55
std::find
T find(T...args)
DataSvcHelpers::RegistryEntry::add
virtual StatusCode add(std::string name, DataObject *pObject, bool is_soft=false)
Add entry to data store.
Definition: RegistryEntry.cpp:208
TsDataSvc::createDefaultObject
virtual DataObject * createDefaultObject() const
Create default objects in case forced creation of leaves is requested.
Definition: TsDataSvc.cpp:1147
IConverter::fillObjRefs
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
std::vector< IRegistry * >
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
TsDataSvc::finalize
StatusCode finalize() override
Service initialization.
Definition: TsDataSvc.cpp:1127
DataSvcHelpers::RegistryEntry::parent
virtual IRegistry * parent() const
Pointer to parent directory entry.
Definition: RegistryEntry.h:126
IDataStoreAgent
Generic data agent interface.
Definition: IDataStoreAgent.h:16
IConversionSvc.h
TsDataSvc::clearSubTree
StatusCode clearSubTree(boost::string_ref sub_tree_path) override
IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name...
Definition: TsDataSvc.cpp:89
std::vector::begin
T begin(T...args)
TsDataSvc::i_setRoot
virtual StatusCode i_setRoot(std::string root_name, DataObject *pRootObj)
Initialize data store for new event by giving new event path and root object.
Definition: TsDataSvc.cpp:169
gaudirun.s
string s
Definition: gaudirun.py:253
DataObject::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:68
TsDataSvc::checkRoot
bool checkRoot()
Check if root path is valid.
Definition: TsDataSvc.h:335
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
TsDataSvc::traverseSubTree
StatusCode traverseSubTree(boost::string_ref sub_tree_path, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full pat...
Definition: TsDataSvc.cpp:128
TsDataSvc::m_forceLeaves
Gaudi::Property< bool > m_forceLeaves
Definition: TsDataSvc.h:72
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
DataSvcHelpers::RegistryEntry::identifier
const std::string & identifier() const override
Full identifier (or key)
Definition: RegistryEntry.h:118
DataSvcHelpers::RegistryEntry::remove
virtual StatusCode remove(boost::string_ref name)
Remove an entry from the store.
Definition: RegistryEntry.cpp:154
TsDataSvc::clearStore
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
Definition: TsDataSvc.cpp:117
StatusCode::FAILURE
Definition: StatusCode.h:29
DataIncident
Data service incident class.
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:84
TsDataSvc::rootCLID
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
Definition: TsDataSvc.cpp:1141
DataIncident.h
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
TsDataSvc::m_inhibitPathes
Gaudi::Property< std::vector< std::string > > m_inhibitPathes
Definition: TsDataSvc.h:73
TsDataSvc::handleDataFault
DataObject * handleDataFault(IRegistry *pReg, boost::string_ref path={})
Invoke data fault handling if enabled.
Definition: TsDataSvc.cpp:541
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
TsDataSvc.h
IConverter.h
STD_LOCK_GUARD_MACRO
#define STD_LOCK_GUARD_MACRO
Definition: TsDataSvc.cpp:46
CAST_REGENTRY
#define CAST_REGENTRY(x, y)
Definition: TsDataSvc.cpp:76
TsDataSvc::loadObject
virtual StatusCode loadObject(IRegistry *pNode)
Invoke Persistency service to create transient object from its persistent representation.
Definition: TsDataSvc.cpp:572
TsDataSvc::registerObject
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject) override
Register object with the data store.
Definition: TsDataSvc.cpp:369
TsDataSvc::objectParent
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object&#39;s parent.
Definition: TsDataSvc.cpp:219
DataSvcHelpers::RegistryEntry::find
virtual IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
Definition: RegistryEntry.h:140
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::operator+
decltype(std::declval< TP >()+std::declval< T >()) operator+(const T &v, const Property< TP, V, H > &p)
implemantation of (value + property)
Definition: Property.h:686
TsDataSvc::m_enableFaultHdlr
Gaudi::Property< bool > m_enableFaultHdlr
Definition: TsDataSvc.h:75
TsDataSvc::m_faultName
Gaudi::Property< std::string > m_faultName
Definition: TsDataSvc.h:77
DataObject.h
TsDataSvc::m_rootName
Gaudi::Property< std::string > m_rootName
Definition: TsDataSvc.h:71
DataSvcHelpers::RegistryEntry::makeHard
void makeHard(DataObject *pObject)
Initialize link as hard link.
Definition: RegistryEntry.cpp:101