Gaudi Framework, version v23r2p1

Home   Generated: Fri Jun 29 2012
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends

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]

List of all members.

Public Types

typedef Store::const_iterator Iterator
 Iterator definition.

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

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_refCount(0),
  m_isSoft(false),
  m_path(path),
  m_pParent(parent),
  m_pAddress(0),
  m_pObject(0),
  m_pDataProviderSvc(0)
{
  std::string::size_type sep = m_path.rfind(SEPARATOR);
  if ( path[0] != SEPARATOR )   {
    m_path.insert(m_path.begin(), SEPARATOR);
  }
  if ( sep != std::string::npos )    {
    m_path.erase(0,sep);
  }
  assemblePath(m_fullpath);
  addRef();
}
DataSvcHelpers::RegistryEntry::~RegistryEntry (  ) [virtual]

Standard Destructor.

Standard destructor.

Definition at line 66 of file RegistryEntry.cpp.

                                             {
  deleteElements();
  if ( 0 != m_pObject  )   {
    if ( !m_isSoft ) m_pObject->setRegistry(0);
    m_pObject->release();
  }
  if ( 0 != m_pAddress )   {
    if ( !m_isSoft ) m_pAddress->setRegistry(0);
    m_pAddress->release();
  }
}

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.

                                                                                                  {
  RegistryEntry* entry = i_add(name);
  if ( 0 != entry )   {
    ( is_soft ) ? entry->makeSoft(pObject) : entry->makeHard(pObject);
    add( entry );
    return StatusCode::SUCCESS;
  }
  return StatusCode::FAILURE;
}
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.

                                                                                                       {
  RegistryEntry* entry = i_add(name);
  if ( 0 != entry )   {
    ( is_soft ) ? entry->makeSoft(pAddress) : entry->makeHard(pAddress);
    add( entry );
    return StatusCode::SUCCESS;
  }
  return StatusCode::FAILURE;
}
long DataSvcHelpers::RegistryEntry::add ( IRegistry obj ) [virtual]

Add object to the container.

Definition at line 195 of file RegistryEntry.cpp.

                                                         {
  try   {
    RegistryEntry* pEntry = CAST_REGENTRY(RegistryEntry*, obj);
    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 (  ) [inline, virtual]

IInterface implementation: Dereference the object.

Implements IRegistry.

Definition at line 112 of file RegistryEntry.h.

                                      {
      return ++m_refCount;
    }
virtual IOpaqueAddress* DataSvcHelpers::RegistryEntry::address (  ) const [inline, virtual]

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 )    {
    m_pParent->assemblePath(buffer);
  }
  buffer += m_path;
}
virtual Iterator DataSvcHelpers::RegistryEntry::begin ( void   ) const [inline, virtual]

Return starting point for container iteration.

Definition at line 156 of file RegistryEntry.h.

                                           {
      return m_store.begin();
    }
virtual IDataProviderSvc* DataSvcHelpers::RegistryEntry::dataSvc (  ) const [inline, virtual]

Retrieve pointer to Transient Store.

Implements IRegistry.

Definition at line 124 of file RegistryEntry.h.

                                               {
      return m_pDataProviderSvc;
    }
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++ )   {
    RegistryEntry* entry = CAST_REGENTRY(RegistryEntry*, *i);
    if ( 0 != entry )   {
      entry->deleteElements();
      entry->release();
    }
  }
  m_store.erase(m_store.begin(), m_store.end());
  return 0;
}
virtual Iterator DataSvcHelpers::RegistryEntry::end ( void   ) const [inline, virtual]

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 [inline, virtual]

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 [inline, virtual]

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 [inline, private]

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 [inline, private]

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 )   {
    std::string path = nam;
    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 );
}
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
    for (Store::const_iterator i = m_store.begin(); i != m_store.end(); i++ )   {
      try   {
        const RegistryEntry *entry = CAST_REGENTRY(RegistryEntry*, *i);
        if( 0 != (result = entry->i_find(key)) )
          return result;
      }
      catch ( ... )   {    }
    }
  }
  return 0;
}
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.

                                                                             {
  Store::const_iterator i = std::find(m_store.begin(),m_store.end(),obj);
  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 loc1 = path.find(SEPARATOR,1);
    std::string::size_type len2 = loc1 != std::string::npos ? loc1 : len;
    for (Store::const_iterator i = m_store.begin(); i != m_store.end(); i++ )   {
      RegistryEntry* regEnt = CAST_REGENTRY(RegistryEntry*, *i);
      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  {
            return CAST_REGENTRY(RegistryEntry*, *i);
          }
        }
        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;
}
virtual const std::string& DataSvcHelpers::RegistryEntry::identifier (  ) const [inline, virtual]

Full identifier (or key)

Implements IRegistry.

Definition at line 120 of file RegistryEntry.h.

                                                   {
      return m_fullpath;
    }
virtual bool DataSvcHelpers::RegistryEntry::isEmpty (  ) const [inline, virtual]

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 [inline, virtual]

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 )   {
    m_pObject->setRegistry(this);
  }
  if ( 0 != m_pAddress )   {
    m_pAddress->setRegistry(this);
  }
}
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 [inline, virtual]

Retrieve name of the entry.

Implements IRegistry.

Definition at line 116 of file RegistryEntry.h.

                                    {
      return m_path;
    }
virtual DataObject* DataSvcHelpers::RegistryEntry::object (  ) const [inline, virtual]

Retrive object behind the link.

Implements IRegistry.

Definition at line 128 of file RegistryEntry.h.

                                            {
      return m_pObject;
    }
virtual IRegistry* DataSvcHelpers::RegistryEntry::parent (  ) const [inline, virtual]

Pointer to parent directory entry.

Definition at line 136 of file RegistryEntry.h.

                                         {
      return m_pParent;
    }
virtual RegistryEntry* DataSvcHelpers::RegistryEntry::parentEntry (  ) [inline, private, virtual]

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 )   {
    std::string path = nam;
    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);
      return StatusCode::SUCCESS;
    }
  }
  return StatusCode::FAILURE;
}
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);
    Store::iterator i = std::remove(m_store.begin(), m_store.end(), pEntry);
    if (i != m_store.end())   {
      pEntry->release();
      m_store.erase( i, m_store.end() );
    }
  }
  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 ) [inline, private]

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 = "";
  assemblePath(m_fullpath);
}
virtual int DataSvcHelpers::RegistryEntry::size ( void   ) const [inline, virtual]

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   {
        RegistryEntry* entry = CAST_REGENTRY(RegistryEntry*, *i);
        entry->traverseTree(pAgent, level+1);
      }
      catch (...)   {
        status = StatusCode::FAILURE;
      }
    }
  }
  return status;
}

Friends And Related Function Documentation

friend class ::DataSvc [friend]

Definition at line 39 of file RegistryEntry.h.


Member Data Documentation

String containing full path of the object (volatile)

Definition at line 48 of file RegistryEntry.h.

Is the link soft or hard?

Definition at line 46 of file RegistryEntry.h.

Pointer to opaque address (load info)

Definition at line 54 of file RegistryEntry.h.

Path name.

Definition at line 50 of file RegistryEntry.h.

Pointer to hosting transient store.

Definition at line 58 of file RegistryEntry.h.

Pointer to object.

Definition at line 56 of file RegistryEntry.h.

Pointer to parent.

Definition at line 52 of file RegistryEntry.h.

Reference counter.

Definition at line 44 of file RegistryEntry.h.

Store of leaves.

Definition at line 60 of file RegistryEntry.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Fri Jun 29 2012 15:44:09 for Gaudi Framework, version v23r2p1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004