Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:39

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_IDATAMANAGERSVC_H
0012 #define GAUDIKERNEL_IDATAMANAGERSVC_H
0013 
0014 // Include files
0015 #include "GaudiKernel/ClassID.h"
0016 #include "GaudiKernel/IDataStoreAgent.h"
0017 #include "GaudiKernel/IInterface.h"
0018 #include <string>
0019 #include <string_view>
0020 #include <vector>
0021 
0022 // Forward declarations
0023 // Generic interface to data object class
0024 #include "GaudiKernel/DataObject.h"
0025 // Interface to persistency service
0026 class IConversionSvc;
0027 // Opaque addresses
0028 class IOpaqueAddress;
0029 // Registry entry definition
0030 class IRegistry;
0031 // Data provider svc
0032 class IDataProviderSvc;
0033 
0034 /** @class IDataManagerSvc IDataManagerSvc.h GaudiKernel/IDataManagerSvc.h
0035 
0036     <P>The data manager interface of the service allows to:
0037     <UL>
0038     <LI> Discard sub-trees or the entire data stored.
0039     <LI> Initialize the top level root used for navigation.
0040     <LI> Access the tree information of the data store:
0041          Given a reference to a store object, which can be identified by
0042          path, pointer or reference to the registry entry, it is possible
0043          to retrieve the parent object and to access iterators over the
0044          leaf entries.
0045     <LI> Register addresses to the data store.
0046          Registered addresses contain the retrieve information for the
0047          underlying object.
0048     <LI> Unregister addresses from the data store. The object will no longer be
0049          accessible and loadable.
0050     </UL>
0051 
0052    @author Markus Frank
0053    @version 1.0
0054 */
0055 struct GAUDI_API IDataManagerSvc : extend_interfaces<IInterface> {
0056   /// InterfaceID
0057   DeclareInterfaceID( IDataManagerSvc, 4, 0 );
0058 
0059   /// Get class ID of root Event
0060   virtual CLID rootCLID() const = 0;
0061 
0062   /// Get Name of root Event
0063   virtual const std::string& rootName() const = 0;
0064 
0065   /** Pass a default data loader to the service. This service will be
0066       asked to load non existant data items.
0067       @param      svc        [IN] Pointer to persistency service instance
0068       @param      dpsvc      [IN] Pointer to data provider instance (optional)
0069       @return                     Status code indicating success or failure
0070   */
0071   virtual StatusCode setDataLoader( IConversionSvc* svc, IDataProviderSvc* dpsvc = nullptr ) = 0;
0072 
0073   /** IDataManagerSvc: Explore the object store: retrieve the object's parent.
0074       The object is identified by its pointer.
0075       @param      pObject     [IN] Pointer to the object.
0076       @param      refpParent [OUT] Reference to store the parent's registry entry.
0077       @return                      Status code indicating success or failure.
0078   */
0079   virtual StatusCode objectParent( const DataObject* pObject, IRegistry*& refpParent ) = 0;
0080 
0081   /** IDataManagerSvc: Explore the object store: retrieve the object's parent.
0082       The object is identified by the pointer to the registry entry.
0083       @param      pRegistry   [IN] Pointer to the object.
0084       @param      refpParent [OUT] Reference to store the parent's registry entry.
0085       @return                      Status code indicating success or failure.
0086   */
0087   virtual StatusCode objectParent( const IRegistry* pRegistry, IRegistry*& refpParent ) = 0;
0088 
0089   /** Explore the object store: retrieve all leaves attached to the object
0090       The object is identified by its pointer.
0091       Allow to access and browse the leaf objects of the identified object.
0092       @param      pObject    [IN] Pointer to the object.
0093       @param      refLeaves  [OUT] Reference to storage location, where
0094                                   the objects leaves should be stored.
0095       @return                     Status code indicating success or failure.
0096   */
0097   virtual StatusCode objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& refLeaves ) = 0;
0098 
0099   /** Explore the object store: retrieve all leaves attached to the object
0100       The object is identified by the pointer to the registry entry.
0101       Allow to access and browse the leaf objects of the identified object.
0102       @param      pRegistry  [IN] Pointer to the registry of the obejct.
0103       @param      refLeaves  [OUT] Reference to storage location, where
0104                                   the objects leaves should be stored.
0105       @return                     Status code indicating success or failure.
0106   */
0107   virtual StatusCode objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& refLeaves ) = 0;
0108 
0109   /** Remove all data objects below the sub tree identified by its full path name.
0110       @param      sub_path   [IN] Path to sub-tree node.
0111       @return                     Status code indicating success or failure.
0112   */
0113   virtual StatusCode clearSubTree( std::string_view sub_path ) = 0;
0114 
0115   /** Remove all data objects below the sub tree
0116       identified by the object. The object itself is removed as well.
0117       @param      pObject    [IN] Pointer to object
0118       @return                     Status code indicating success or failure
0119   */
0120   virtual StatusCode clearSubTree( DataObject* pObject ) = 0;
0121 
0122   /** Remove all data objects in the data store.
0123       @return                     Status code indicating success or failure
0124   */
0125   virtual StatusCode clearStore() = 0;
0126 
0127   /** Analyse by traversing all data objects below the sub tree identified by its full path name.
0128       @param      sub_path   [IN] Path to sub-tree node.
0129       @return                     Status code indicating success or failure.
0130   */
0131   virtual StatusCode traverseSubTree( std::string_view sub_tree_path, IDataStoreAgent* pAgent ) = 0;
0132 
0133   /** Analyse by traversing all data objects below the sub tree identified by its full path name.
0134       @param      sub_path   [IN] Path to sub-tree node.
0135       @param      f          [IN] callable which will be called for each data object
0136                                   it should have the signature bool(IRegistry*,int level)
0137       @return                     Status code indicating success or failure.
0138   */
0139   template <typename F, typename = std::enable_if_t<!std::is_convertible_v<F, IDataStoreAgent*>>>
0140   StatusCode traverseSubTree( std::string_view sub_path, F&& f ) {
0141     auto agent = makeDataStoreAgent( std::forward<F>( f ) );
0142     return traverseSubTree( sub_path, &agent );
0143   }
0144 
0145   /** Analyse by traversing all data objects below the sub tree
0146       identified by the object. The object itself is removed as well.
0147       @param      pObject    [IN] Pointer to object
0148       @param      pAgent     [IN] Pointer to the datastore agent traversing the store
0149       @return                     Status code indicating success or failure
0150   */
0151   virtual StatusCode traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent ) = 0;
0152 
0153   /** Analyse by traversing all data objects below the sub tree
0154       identified by the object. The object itself is removed as well.
0155       @param      pObject    [IN] Pointer to object
0156       @param      f          [IN] Callable which will be called on each data object
0157                                   it should have the signature bool(IRegistry*,int level)
0158       @return                     Status code indicating success or failure
0159   */
0160   template <typename F, typename = std::enable_if_t<!std::is_convertible_v<F, IDataStoreAgent*>>>
0161   StatusCode traverseSubTree( DataObject* pObject, F&& f ) {
0162     auto agent = makeDataStoreAgent( std::forward<F>( f ) );
0163     return traverseSubTree( pObject, &agent );
0164   }
0165 
0166   /** Analyse by traversing all data objects in the data store.
0167       @return     Status code indicating success or failure
0168   */
0169   virtual StatusCode traverseTree( IDataStoreAgent* pAgent ) = 0;
0170 
0171   /** Analyse by traversing all data objects in the data store.
0172       @param      f          [IN] callable which will be called for each data object
0173                                   it should have the signature bool(IRegistry*,int level)
0174       @return     Status code indicating success or failure
0175   */
0176   template <typename F, typename = std::enable_if_t<!std::is_convertible_v<F, IDataStoreAgent*>>>
0177   StatusCode traverseTree( F&& f ) {
0178     auto agent = makeDataStoreAgent( std::forward<F>( f ) );
0179     return traverseTree( &agent );
0180   }
0181 
0182   /** Initialize data store for new event by giving new event path.
0183       Implicitly this clears the entire data store.
0184       @param      root_name  [IN] String containing root path name
0185       @param      pObject    [IN] Pointer to root node object
0186       @return                     Status code indicating success or failure
0187   */
0188   virtual StatusCode setRoot( std::string root_name, DataObject* pObject ) = 0;
0189 
0190   /** Initialize data store for new event by giving new event path.
0191       Implicitly this clears the entire data store.
0192       @param      root_name  [IN] String containing root path name
0193       @param      pRootAddr  [IN] Pointer to opaque root node address
0194       @return                     Status code indicating success or failure
0195   */
0196   virtual StatusCode setRoot( std::string root_path, IOpaqueAddress* pRootAddr ) = 0;
0197 
0198   /** Register object address with the data store.
0199      Connect the object identified by its pointer to the node object
0200      identified by its path.
0201      @param      fullPath    [IN] Path to parent node of the object.
0202      @param      pAddress    [IN] Pointer to the object to be registered.
0203       @return                     Status code indicating success or failure.
0204   */
0205   virtual StatusCode registerAddress( std::string_view fullPath, IOpaqueAddress* pAddress ) = 0;
0206 
0207   /** Register object address with the data store.
0208       Connect the object identified by its pointer to the parent object
0209       and the relative path of the object with respect to the parent.
0210       @param      parentObj  [IN] Pointer to parent object.
0211       @param      objectPath [IN] Path of the object relative to the parent node
0212       @param      pAddress   [IN] Pointer to the object to be connected.
0213       @return                     Status code indicating success or failure.
0214   */
0215   StatusCode registerAddress( DataObject* parentObj, std::string_view objectPath, IOpaqueAddress* pAddress ) {
0216     return registerAddress( parentObj ? parentObj->registry() : nullptr, objectPath, pAddress );
0217   }
0218 
0219   /** Register object address with the data store.
0220       Connect the object identified by its pointer to the parent object
0221       and the relative path of the object with respect to the parent.
0222       @param      parentObj  [IN] Pointer to parent object.
0223       @param      objectPath [IN] Path of the object relative to the parent node
0224       @param      pAddress   [IN] Pointer to the object to be connected.
0225       @return                     Status code indicating success or failure.
0226   */
0227   virtual StatusCode registerAddress( IRegistry* parentObj, std::string_view objectPath, IOpaqueAddress* pAddress ) = 0;
0228 
0229   /** Unregister object address from the data store.
0230       The object is identified by full path name.
0231       @param      fullPath [IN] Path name of the object.
0232       @return                   Status code indicating success or failure.
0233   */
0234   virtual StatusCode unregisterAddress( std::string_view fullPath ) = 0;
0235 
0236   /** Unregister object address from the data store.
0237       The object is identified by parent object and the path of the
0238       object relative to the parent.
0239       @param      pParent  [IN] Pointer to parent object.
0240       @param      objPath  [IN] Path name of the object relative to the parent.
0241       @return                   Status code indicating success or failure.
0242   */
0243   StatusCode unregisterAddress( DataObject* pParent, std::string_view objPath ) {
0244     return unregisterAddress( pParent ? pParent->registry() : nullptr, objPath );
0245   }
0246 
0247   /** Unregister object address from the data store.
0248       The object is identified by parent object and the path of the
0249       object relative to the parent.
0250       @param      pParent  [IN] Pointer to parent object.
0251       @param      objPath  [IN] Path name of the object relative to the parent.
0252       @return                   Status code indicating success or failure.
0253   */
0254   virtual StatusCode unregisterAddress( IRegistry* pParent, std::string_view objPath ) = 0;
0255 };
0256 
0257 #endif // GAUDIKERNEL_IDATAMANAGERSVC_H