Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
DataSvcHelpers::RegistryEntry Class Reference

Definition of an entry in the transient data store. More...

#include <GaudiKernel/RegistryEntry.h>

Inheritance diagram for DataSvcHelpers::RegistryEntry:
Inheritance graph
[legend]
Collaboration diagram for DataSvcHelpers::RegistryEntry:
Collaboration graph
[legend]

Public Types

typedef Store::const_iterator Iterator
 Iterator definition.
 
- Public Types inherited from IRegistry
typedef std::string name_type
 Type definitions Name type.
 
typedef std::string id_type
 Identifier Key type.
 

Public Member Functions

 RegistryEntry (const std::string &path, RegistryEntry *parent=0)
 Standard Constructor.
 
virtual ~RegistryEntry ()
 Standard Destructor.
 
virtual unsigned long release ()
 IInterface implementation: Reference the object.
 
virtual unsigned long addRef ()
 IInterface implementation: Dereference the object.
 
const std::stringname () const
 Retrieve name of the entry.
 
virtual const std::stringidentifier () const
 Full identifier (or key)
 
virtual IDataProviderSvcdataSvc () const
 Retrieve pointer to Transient Store.
 
virtual DataObjectobject () const
 Retrive object behind the link.
 
virtual IOpaqueAddressaddress () const
 Retrieve opaque storage address.
 
virtual IRegistryparent () const
 Pointer to parent directory entry.
 
virtual bool isSoft () const
 Is the link soft or hard.
 
const Storeleaves () const
 Access the leaves of the object.
 
virtual int size () const
 Return the size of the container(=number of objects)
 
virtual bool isEmpty () const
 Simple check if the Container is empty.
 
virtual Iterator begin () const
 Return starting point for container iteration.
 
virtual Iterator end () const
 Return end elemtn if the container.
 
virtual IRegistryfind (const IRegistry *obj) const
 Try to find an object identified by its pointer.
 
virtual IRegistryfind (const std::string &path) const
 Try to find an object identified by its relative name to the directory.
 
void setAddress (IOpaqueAddress *pAddress)
 Set/Update Opaque address.
 
void setObject (DataObject *obj)
 Set/Update object address.
 
virtual long add (const std::string &name, DataObject *pObject, bool is_soft=false)
 Add entry to data store.
 
virtual long add (const std::string &name, IOpaqueAddress *pAddress, bool is_soft=false)
 Add entry to data store.
 
virtual long remove (const std::string &name)
 Remove an entry from the store.
 
virtual long add (IRegistry *obj)
 Add object to the container.
 
virtual long remove (IRegistry *obj)
 Remove an object from the container.
 
virtual long deleteElements ()
 Delete all contained elements.
 
virtual long traverseTree (IDataStoreAgent *pAgent, int level=0)
 traverse data tree
 
- Public Member Functions inherited from IRegistry
virtual ~IRegistry ()
 destructor
 

Private Types

typedef std::vector< IRegistry * > Store
 Definition of datastore type.
 

Private Member Functions

void assemblePath (std::string &buffer) const
 The following entries serve two aspects: 1) They are faster for recursive calls, because they are non-virtual 2) They can be re-used for the non-const entry points using a const_cast of the result.
 
IRegistryi_find (const IRegistry *pDirectory) const
 Internal method to retrieve data directory.
 
RegistryEntryi_find (const std::string &path) const
 Internal method to retrieve data directory.
 
RegistryEntryi_find (const DataObject *pObject) const
 Internal method to locate object entry.
 
RegistryEntryi_add (const std::string &name)
 Internal method to add entries.
 
void setParent (RegistryEntry *pParent)
 Set new parent pointer.
 
void setDataSvc (IDataProviderSvc *s)
 Set the transient data store.
 
virtual RegistryEntryparentEntry ()
 Pointer to parent registry entry.
 
RegistryEntryfindLeaf (const std::string &path) const
 Find identified leaf in this registry node.
 
RegistryEntryfindLeaf (const DataObject *key) const
 Find identified leaf in this registry node.
 
void makeHard (DataObject *pObject)
 Initialize link as hard link.
 
void makeHard (IOpaqueAddress *pAddress)
 Initialize link as hard link.
 
void makeSoft (DataObject *pObject)
 Initialize link as soft link.
 
void makeSoft (IOpaqueAddress *pAddress)
 Initialize link as soft link.
 

Private Attributes

unsigned long m_refCount
 Reference counter.
 
bool m_isSoft
 Is the link soft or hard?
 
std::string m_fullpath
 String containing full path of the object (volatile)
 
std::string m_path
 Path name.
 
RegistryEntrym_pParent
 Pointer to parent.
 
IOpaqueAddressm_pAddress
 Pointer to opaque address (load info)
 
DataObjectm_pObject
 Pointer to object.
 
IDataProviderSvcm_pDataProviderSvc
 Pointer to hosting transient store.
 
Store m_store
 Store of leaves.
 

Friends

class ::DataSvc
 

Detailed Description

Definition of an entry in the transient data store.

The RegistryEntry represents an entry of the transient data store. The object holds the recipe how to retrieve objects from the persistent world (member IOpaqueAddress) as well as the backward link to the parent entry and the leaves.

Author
Markus Frank
Sebastien Ponce

Definition at line 34 of file RegistryEntry.h.

Member Typedef Documentation

Iterator definition.

Definition at line 41 of file RegistryEntry.h.

Definition of datastore type.

Definition at line 37 of file RegistryEntry.h.

Constructor & Destructor Documentation

DataSvcHelpers::RegistryEntry::RegistryEntry ( const std::string path,
RegistryEntry parent = 0 
)

Standard Constructor.

Definition at line 45 of file RegistryEntry.cpp.

m_isSoft(false),
{
if ( path[0] != SEPARATOR ) {
m_path.insert(m_path.begin(), SEPARATOR);
}
if ( sep != std::string::npos ) {
m_path.erase(0,sep);
}
addRef();
}
DataSvcHelpers::RegistryEntry::~RegistryEntry ( )
virtual

Standard Destructor.

Standard destructor.

Definition at line 66 of file RegistryEntry.cpp.

{
if ( 0 != m_pObject ) {
}
if ( 0 != m_pAddress ) {
}
}

Member Function Documentation

long DataSvcHelpers::RegistryEntry::add ( const std::string name,
DataObject pObject,
bool  is_soft = false 
)
virtual

Add entry to data store.

Add entry to the current data store item.

Definition at line 211 of file RegistryEntry.cpp.

{
if ( 0 != entry ) {
( is_soft ) ? entry->makeSoft(pObject) : entry->makeHard(pObject);
add( entry );
}
}
long DataSvcHelpers::RegistryEntry::add ( const std::string name,
IOpaqueAddress pAddress,
bool  is_soft = false 
)
virtual

Add entry to data store.

Add entry to the current data store item.

Definition at line 222 of file RegistryEntry.cpp.

{
if ( 0 != entry ) {
( is_soft ) ? entry->makeSoft(pAddress) : entry->makeHard(pAddress);
add( entry );
}
}
long DataSvcHelpers::RegistryEntry::add ( IRegistry obj)
virtual

Add object to the container.

Definition at line 195 of file RegistryEntry.cpp.

{
try {
pEntry->setDataSvc(m_pDataProviderSvc);
m_store.push_back(pEntry);
pEntry->setParent(this);
if ( !pEntry->isSoft() && pEntry->address() != 0 ) {
pEntry->address()->setRegistry(pEntry);
}
}
catch ( ... ) {
}
return m_store.size();
}
virtual unsigned long DataSvcHelpers::RegistryEntry::addRef ( )
inlinevirtual

IInterface implementation: Dereference the object.

Implements IRegistry.

Definition at line 112 of file RegistryEntry.h.

{
return ++m_refCount;
}
virtual IOpaqueAddress* DataSvcHelpers::RegistryEntry::address ( ) const
inlinevirtual

Retrieve opaque storage address.

Implements IRegistry.

Definition at line 132 of file RegistryEntry.h.

{
return m_pAddress;
}
void DataSvcHelpers::RegistryEntry::assemblePath ( std::string buffer) const
private

The following entries serve two aspects: 1) They are faster for recursive calls, because they are non-virtual 2) They can be re-used for the non-const entry points using a const_cast of the result.

Recursive helper to assemble the full path name of the entry

Definition at line 339 of file RegistryEntry.cpp.

{
if ( m_pParent != 0 ) {
}
buffer += m_path;
}
virtual Iterator DataSvcHelpers::RegistryEntry::begin ( ) const
inlinevirtual

Return starting point for container iteration.

Definition at line 156 of file RegistryEntry.h.

{
return m_store.begin();
}
virtual IDataProviderSvc* DataSvcHelpers::RegistryEntry::dataSvc ( ) const
inlinevirtual

Retrieve pointer to Transient Store.

Implements IRegistry.

Definition at line 124 of file RegistryEntry.h.

{
}
long DataSvcHelpers::RegistryEntry::deleteElements ( )
virtual

Delete all contained elements.

Delete recursively all elements pending from the current store item.

Definition at line 233 of file RegistryEntry.cpp.

{
for (Store::iterator i = m_store.begin(); i != m_store.end(); i++ ) {
if ( 0 != entry ) {
entry->deleteElements();
entry->release();
}
}
return 0;
}
virtual Iterator DataSvcHelpers::RegistryEntry::end ( ) const
inlinevirtual

Return end elemtn if the container.

Definition at line 160 of file RegistryEntry.h.

{
return m_store.end();
}
virtual IRegistry* DataSvcHelpers::RegistryEntry::find ( const IRegistry obj) const
inlinevirtual

Try to find an object identified by its pointer.

Definition at line 164 of file RegistryEntry.h.

{
return i_find(obj);
}
virtual IRegistry* DataSvcHelpers::RegistryEntry::find ( const std::string path) const
inlinevirtual

Try to find an object identified by its relative name to the directory.

Definition at line 168 of file RegistryEntry.h.

{
return i_find(path);
}
RegistryEntry* DataSvcHelpers::RegistryEntry::findLeaf ( const std::string path) const
inlineprivate

Find identified leaf in this registry node.

Definition at line 89 of file RegistryEntry.h.

{
return i_find(path);
}
RegistryEntry* DataSvcHelpers::RegistryEntry::findLeaf ( const DataObject key) const
inlineprivate

Find identified leaf in this registry node.

Definition at line 93 of file RegistryEntry.h.

{
return i_find(key);
}
DataSvcHelpers::RegistryEntry * DataSvcHelpers::RegistryEntry::i_add ( const std::string name)
private

Internal method to add entries.

Definition at line 179 of file RegistryEntry.cpp.

{
if ( nam[0] != SEPARATOR ) {
path.insert(path.begin(), SEPARATOR);
return i_add(path);
}
// if this object is already present, this is an error....
for (Store::iterator i = m_store.begin(); i != m_store.end(); i++ ) {
if ( nam == (*i)->name() ) {
return 0;
}
}
return new RegistryEntry( nam, this );
}
IRegistry * DataSvcHelpers::RegistryEntry::i_find ( const IRegistry pDirectory) const
private

Internal method to retrieve data directory.

Try to find an object identified by its pointer.

Definition at line 246 of file RegistryEntry.cpp.

{
return (i==m_store.end()) ? 0 : (*i);
}
DataSvcHelpers::RegistryEntry * DataSvcHelpers::RegistryEntry::i_find ( const std::string path) const
private

Internal method to retrieve data directory.

Find identified leaf in this registry node.

Definition at line 252 of file RegistryEntry.cpp.

{
if ( path[0] != SEPARATOR ) {
std::string thePath = path;
thePath.insert(thePath.begin(), SEPARATOR);
return i_find(thePath);
}
else {
std::string::size_type len = path.length();
std::string::size_type len2 = loc1 != std::string::npos ? loc1 : len;
const std::string& nam = regEnt->name();
// check that the first len2 chars of path are the same as nam
// (i.e. match {len2:3 nam:"/Ab" path:"/Ab/C"}
// but not {len2:3 nam:"/Abc" path:"/Ab/C"})
if ( path.compare(0, len2, nam) == 0 ) {
try {
if ( loc1 != std::string::npos ) {
std::string search_path(path, loc1, len);
IRegistry* pDir = regEnt->find(search_path);
if ( 0 != pDir ) {
return CAST_REGENTRY(RegistryEntry*, pDir);
}
return 0;
}
else {
}
}
catch (...) {
}
}
}
// If this node is "/NodeA", this part allows to find "/NodeA/NodeB" as
// our "/NodeB" child.
if ( path.compare(0, len2, m_path) == 0 ) {
if (len2 < len) {
std::string search_path(path, loc1, len);
return i_find(search_path);
}
}
}
return 0;
}
DataSvcHelpers::RegistryEntry * DataSvcHelpers::RegistryEntry::i_find ( const DataObject pObject) const
private

Internal method to locate object entry.

Find identified leaf in this registry node.

Definition at line 299 of file RegistryEntry.cpp.

{
if ( 0 != key ) {
if ( key == m_pObject ) {
return const_cast<RegistryEntry*>(this);
}
// Look in the immediate level:
RegistryEntry *result = CAST_REGENTRY(RegistryEntry*, i_find(key->registry()));
if ( 0 != result ) return result;
// Go levels down
try {
if( 0 != (result = entry->i_find(key)) )
return result;
}
catch ( ... ) { }
}
}
return 0;
}
virtual const std::string& DataSvcHelpers::RegistryEntry::identifier ( ) const
inlinevirtual

Full identifier (or key)

Implements IRegistry.

Definition at line 120 of file RegistryEntry.h.

{
return m_fullpath;
}
virtual bool DataSvcHelpers::RegistryEntry::isEmpty ( ) const
inlinevirtual

Simple check if the Container is empty.

Definition at line 152 of file RegistryEntry.h.

{
return m_store.size() == 0;
}
virtual bool DataSvcHelpers::RegistryEntry::isSoft ( ) const
inlinevirtual

Is the link soft or hard.

Definition at line 140 of file RegistryEntry.h.

{
return m_isSoft;
}
const Store& DataSvcHelpers::RegistryEntry::leaves ( ) const
inline

Access the leaves of the object.

Definition at line 144 of file RegistryEntry.h.

{
return m_store;
}
void DataSvcHelpers::RegistryEntry::makeHard ( DataObject pObject)
private

Initialize link as hard link.

Create hard link.

Definition at line 110 of file RegistryEntry.cpp.

{
makeSoft(pObject);
m_isSoft = false;
if ( 0 != m_pObject ) {
}
if ( 0 != m_pAddress ) {
}
}
void DataSvcHelpers::RegistryEntry::makeHard ( IOpaqueAddress pAddress)
private

Initialize link as hard link.

Create hard link.

Definition at line 122 of file RegistryEntry.cpp.

{
m_isSoft = false;
setAddress(pAddress);
}
void DataSvcHelpers::RegistryEntry::makeSoft ( DataObject pObject)
private

Initialize link as soft link.

Create soft link.

Definition at line 95 of file RegistryEntry.cpp.

{
m_isSoft = true;
setObject(pObject);
// if ( 0 != m_pObject ) { // Useless: This justs sets my own address again...
// setAddress(m_pObject->address());
// }
}
void DataSvcHelpers::RegistryEntry::makeSoft ( IOpaqueAddress pAddress)
private

Initialize link as soft link.

Create soft link.

Definition at line 104 of file RegistryEntry.cpp.

{
m_isSoft = true;
setAddress(pAddress);
}
const std::string& DataSvcHelpers::RegistryEntry::name ( ) const
inlinevirtual

Retrieve name of the entry.

Implements IRegistry.

Definition at line 116 of file RegistryEntry.h.

{
return m_path;
}
virtual DataObject* DataSvcHelpers::RegistryEntry::object ( ) const
inlinevirtual

Retrive object behind the link.

Implements IRegistry.

Definition at line 128 of file RegistryEntry.h.

{
return m_pObject;
}
virtual IRegistry* DataSvcHelpers::RegistryEntry::parent ( ) const
inlinevirtual

Pointer to parent directory entry.

Definition at line 136 of file RegistryEntry.h.

{
return m_pParent;
}
virtual RegistryEntry* DataSvcHelpers::RegistryEntry::parentEntry ( )
inlineprivatevirtual

Pointer to parent registry entry.

Definition at line 85 of file RegistryEntry.h.

{
return m_pParent;
}
unsigned long DataSvcHelpers::RegistryEntry::release ( )
virtual

IInterface implementation: Reference the object.

Release entry.

Implements IRegistry.

Definition at line 79 of file RegistryEntry.cpp.

{
unsigned long cnt = --m_refCount;
if ( 0 == m_refCount ) {
delete this;
}
return cnt;
}
long DataSvcHelpers::RegistryEntry::remove ( const std::string name)
virtual

Remove an entry from the store.

Remove entry from data store.

Definition at line 162 of file RegistryEntry.cpp.

{
if ( nam[0] != SEPARATOR ) {
path.insert(path.begin(), SEPARATOR);
return remove(path);
}
// if this object is already present, this is an error....
for (Store::iterator i = m_store.begin(); i != m_store.end(); i++ ) {
if ( nam == (*i)->name() ) {
remove(*i);
}
}
}
long DataSvcHelpers::RegistryEntry::remove ( IRegistry obj)
virtual

Remove an object from the container.

Definition at line 148 of file RegistryEntry.cpp.

{
try {
RegistryEntry* pEntry = dynamic_cast<RegistryEntry*>(obj);
if (i != m_store.end()) {
pEntry->release();
}
}
catch ( ... ) { }
return m_store.size();
}
void DataSvcHelpers::RegistryEntry::setAddress ( IOpaqueAddress pAddress)
virtual

Set/Update Opaque address.

Update Opaque address of registry entry.

Implements IRegistry.

Definition at line 128 of file RegistryEntry.cpp.

{
if ( 0 != pAddress ) {
pAddress->addRef();
pAddress->setRegistry(this);
}
if ( 0 != m_pAddress ) m_pAddress->release();
m_pAddress = pAddress;
}
void DataSvcHelpers::RegistryEntry::setDataSvc ( IDataProviderSvc s)
inlineprivate

Set the transient data store.

Definition at line 81 of file RegistryEntry.h.

void DataSvcHelpers::RegistryEntry::setObject ( DataObject obj)

Set/Update object address.

Set object pointer of data store item.

Definition at line 138 of file RegistryEntry.cpp.

{
if ( 0 != pObject ) {
pObject->addRef();
if ( !isSoft() ) pObject->setRegistry(this);
}
if ( 0 != m_pObject ) m_pObject->release();
m_pObject = pObject;
}
void DataSvcHelpers::RegistryEntry::setParent ( RegistryEntry pParent)
private

Set new parent pointer.

Definition at line 88 of file RegistryEntry.cpp.

{
m_pParent = pParent;
m_fullpath = "";
}
virtual int DataSvcHelpers::RegistryEntry::size ( ) const
inlinevirtual

Return the size of the container(=number of objects)

Definition at line 148 of file RegistryEntry.h.

{
return m_store.size();
}
long DataSvcHelpers::RegistryEntry::traverseTree ( IDataStoreAgent pAgent,
int  level = 0 
)
virtual

traverse data tree

Definition at line 321 of file RegistryEntry.cpp.

{
bool go_down = pAgent->analyse(this, level);
long status = StatusCode::SUCCESS;
if ( go_down ) {
for ( Store::iterator i = m_store.begin(); i != m_store.end(); i++ ) {
try {
entry->traverseTree(pAgent, level+1);
}
catch (...) {
}
}
}
return status;
}

Friends And Related Function Documentation

friend class ::DataSvc
friend

Definition at line 39 of file RegistryEntry.h.

Member Data Documentation

std::string DataSvcHelpers::RegistryEntry::m_fullpath
private

String containing full path of the object (volatile)

Definition at line 48 of file RegistryEntry.h.

bool DataSvcHelpers::RegistryEntry::m_isSoft
private

Is the link soft or hard?

Definition at line 46 of file RegistryEntry.h.

IOpaqueAddress* DataSvcHelpers::RegistryEntry::m_pAddress
private

Pointer to opaque address (load info)

Definition at line 54 of file RegistryEntry.h.

std::string DataSvcHelpers::RegistryEntry::m_path
private

Path name.

Definition at line 50 of file RegistryEntry.h.

IDataProviderSvc* DataSvcHelpers::RegistryEntry::m_pDataProviderSvc
private

Pointer to hosting transient store.

Definition at line 58 of file RegistryEntry.h.

DataObject* DataSvcHelpers::RegistryEntry::m_pObject
private

Pointer to object.

Definition at line 56 of file RegistryEntry.h.

RegistryEntry* DataSvcHelpers::RegistryEntry::m_pParent
private

Pointer to parent.

Definition at line 52 of file RegistryEntry.h.

unsigned long DataSvcHelpers::RegistryEntry::m_refCount
private

Reference counter.

Definition at line 44 of file RegistryEntry.h.

Store DataSvcHelpers::RegistryEntry::m_store
private

Store of leaves.

Definition at line 60 of file RegistryEntry.h.


The documentation for this class was generated from the following files:

Generated at Thu Jul 18 2013 12:18:13 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004