The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
RegistryEntry.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
14#include <GaudiKernel/Kernel.h>
16#include <string_view>
17#include <vector>
18
19class DataSvc;
20// DP add this fwd decl for thread safety
21class TsDataSvc;
22class DataObject;
24class IOpaqueAddress;
25class IDataStoreAgent;
26
27namespace DataSvcHelpers {
41 class GAUDI_API RegistryEntry final : public IRegistry {
42 private:
44 typedef std::vector<IRegistry*> Store;
45
46 public:
47 friend class ::DataSvc;
48 // DP add friend class: the thread safe version of the DataSvc
49 friend class ::TsDataSvc;
51 typedef Store::const_iterator Iterator;
52
53 private:
55 unsigned long m_refCount = 0;
57 bool m_isSoft = false;
59 std::string m_fullpath;
61 std::string m_path;
72
73 private:
80 void assemblePath( std::string& buffer ) const;
82 IRegistry* i_find( const IRegistry* pDirectory ) const;
84 RegistryEntry* i_find( std::string_view path ) const;
86 RegistryEntry* i_find( const DataObject* pObject ) const;
88 RegistryEntry* i_create( std::string name );
90 long i_add( RegistryEntry* entry );
92 void setParent( RegistryEntry* pParent );
98 RegistryEntry* findLeaf( std::string_view path ) const { return i_find( path ); }
100 RegistryEntry* findLeaf( const DataObject* key ) const { return i_find( key ); }
102 void makeHard( DataObject* pObject );
104 void makeHard( IOpaqueAddress* pAddress );
106 void makeSoft( DataObject* pObject );
108 void makeSoft( IOpaqueAddress* pAddress );
109
110 public:
112 RegistryEntry( std::string path, RegistryEntry* parent = nullptr );
114 ~RegistryEntry() override;
116 unsigned long release() override;
118 unsigned long addRef() override { return ++m_refCount; }
120 const std::string& name() const override { return m_path; }
122 const std::string& identifier() const override { return m_fullpath; }
124 IDataProviderSvc* dataSvc() const override { return m_pDataProviderSvc; }
126 DataObject* object() const override { return m_pObject; }
128 IOpaqueAddress* address() const override { return m_pAddress; }
130 IRegistry* parent() const { return m_pParent; }
132 bool isSoft() const { return m_isSoft; }
134 const Store& leaves() const { return m_store; }
136 size_t size() const { return m_store.size(); }
138 bool isEmpty() const { return m_store.size() == 0; }
140 Iterator begin() const { return m_store.begin(); }
142 Iterator end() const { return m_store.end(); }
144 IRegistry* find( const IRegistry* obj ) const { return i_find( obj ); }
146 IRegistry* find( std::string_view path ) const { return i_find( path ); }
148 void setAddress( IOpaqueAddress* pAddress ) override;
150 void setObject( DataObject* obj );
151
153 StatusCode add( std::string name, DataObject* pObject, bool is_soft = false );
155 StatusCode add( std::string name, IOpaqueAddress* pAddress, bool is_soft = false );
157 StatusCode remove( std::string_view name );
159 long add( IRegistry* obj );
161 long remove( IRegistry* obj );
163 long deleteElements();
165 StatusCode traverseTree( IDataStoreAgent* pAgent, int level = 0 );
166 };
167} // namespace DataSvcHelpers
#define GAUDI_API
Definition Kernel.h:49
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
Definition of an entry in the transient data store.
size_t size() const
Return the size of the container(=number of objects)
IDataProviderSvc * m_pDataProviderSvc
Pointer to hosting transient store.
std::vector< IRegistry * > Store
Definition of datastore type.
std::string m_fullpath
String containing full path of the object (volatile)
unsigned long addRef() override
IInterface implementation: Dereference the object.
IRegistry * find(std::string_view path) const
Try to find an object identified by its relative name to the directory.
Store m_store
Store of leaves.
unsigned long m_refCount
Reference counter.
RegistryEntry * i_create(std::string name)
Internal method to create entries.
IDataProviderSvc * dataSvc() const override
Retrieve pointer to Transient Store.
IRegistry * parent() const
Pointer to parent directory entry.
void setParent(RegistryEntry *pParent)
Set new parent pointer.
Iterator end() const
Return end elemtn if the container.
IRegistry * i_find(const IRegistry *pDirectory) const
Internal method to retrieve data directory.
const Store & leaves() const
Access the leaves of the object.
void assemblePath(std::string &buffer) const
The following entries serve two aspects: 1) They are faster for recursive calls, because they are non...
void setDataSvc(IDataProviderSvc *s)
Set the transient data store.
bool isSoft() const
Is the link soft or hard.
RegistryEntry * m_pParent
Pointer to parent.
DataObject * m_pObject
Pointer to object.
bool m_isSoft
Is the link soft or hard?
const std::string & identifier() const override
Full identifier (or key)
RegistryEntry * findLeaf(std::string_view path) const
Find identified leaf in this registry node.
RegistryEntry * findLeaf(const DataObject *key) const
Find identified leaf in this registry node.
long i_add(RegistryEntry *entry)
Internal method to add entries.
IRegistry * find(const IRegistry *obj) const
Try to find an object identified by its pointer.
Store::const_iterator Iterator
Iterator definition.
RegistryEntry * parentEntry()
Pointer to parent registry entry.
DataObject * object() const override
Retrive object behind the link.
std::string m_path
Path name.
bool isEmpty() const
Simple check if the Container is empty.
Iterator begin() const
Return starting point for container iteration.
IOpaqueAddress * m_pAddress
Pointer to opaque address (load info)
IOpaqueAddress * address() const override
Retrieve opaque storage address.
RegistryEntry(std::string path, RegistryEntry *parent=nullptr)
Standard Constructor.
const std::string & name() const override
Retrieve name of the entry.
Data service base class.
Definition DataSvc.h:43
Data provider interface definition.
Generic data agent interface.
Opaque address interface definition.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Data service base class.
Definition TsDataSvc.h:53