Gaudi Framework, version v21r8

Home   Generated: 17 Mar 2010

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

Definition of datastore type.

Definition at line 37 of file RegistryEntry.h.

Iterator definition.

Definition at line 41 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.

00046 : m_refCount(0), 
00047   m_isSoft(false), 
00048   m_path(path),
00049   m_pParent(parent),
00050   m_pAddress(0),
00051   m_pObject(0), 
00052   m_pDataProviderSvc(0)
00053 {
00054   std::string::size_type sep = m_path.rfind(SEPARATOR);
00055   if ( path[0] != SEPARATOR )   {
00056     m_path.insert(m_path.begin(), SEPARATOR);
00057   }
00058   if ( sep != std::string::npos )    {
00059     m_path.erase(0,sep);
00060   }
00061   assemblePath(m_fullpath);
00062   addRef();
00063 }

DataSvcHelpers::RegistryEntry::~RegistryEntry (  )  [virtual]

Standard Destructor.

Standard destructor.

Definition at line 66 of file RegistryEntry.cpp.

00066                                              {
00067   deleteElements();
00068   if ( 0 != m_pObject  )   {
00069     if ( !m_isSoft ) m_pObject->setRegistry(0);
00070     m_pObject->release();
00071   }
00072   if ( 0 != m_pAddress )   {
00073     if ( !m_isSoft ) m_pAddress->setRegistry(0);
00074     m_pAddress->release();
00075   }
00076 }


Member Function Documentation

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 340 of file RegistryEntry.cpp.

00340                                                                         {
00341   if ( m_pParent != 0 )    {
00342     m_pParent->assemblePath(buffer);
00343   }
00344   buffer += m_path;
00345 }

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.

00246                                                                              {
00247   Store::const_iterator i = std::find(m_store.begin(),m_store.end(),obj);
00248   return (i==m_store.end()) ? 0 : (*i);
00249 }

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.

00252                                                                                                  {
00253   if ( path[0] != SEPARATOR )    {
00254     std::string thePath = path;
00255     thePath.insert(thePath.begin(), SEPARATOR);
00256     return i_find(thePath);
00257   }
00258   else  {
00259     std::string::size_type len  = path.length();
00260     std::string::size_type loc1 = path.find(SEPARATOR,1);
00261     std::string::size_type len2 = loc1 != std::string::npos ? loc1 : len;
00262     const char* data = path.data();
00263     for (Store::const_iterator i = m_store.begin(); i != m_store.end(); i++ )   {
00264       RegistryEntry* regEnt = CAST_REGENTRY(RegistryEntry*, *i);
00265       const std::string& nam = regEnt->name();
00266       if ( nam.length() == len2 )   {
00267         if ( std::equal(nam.begin(), nam.begin()+len2, data)  )    {
00268           try   {
00269             if ( loc1 != std::string::npos )   {
00270               std::string search_path(path, loc1, len);
00271               IRegistry* pDir = regEnt->find(search_path);
00272               if ( 0 != pDir )    {
00273                 return CAST_REGENTRY(RegistryEntry*, pDir);
00274               }
00275               return 0;
00276             }
00277             else  {
00278               return CAST_REGENTRY(RegistryEntry*, *i);
00279             }
00280           }
00281           catch (...)   {
00282           }
00283         }
00284       }
00285     }
00286     if ( m_path.length() == len2 )    {
00287       if ( std::equal(m_path.begin(), m_path.begin()+len2, data)  )    {
00288         if (len2 < len)   {
00289           std::string search_path(path, loc1, len);
00290           return i_find(search_path);
00291         }
00292         //return this;
00293       }
00294     }
00295   }
00296   return 0;
00297 }

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 300 of file RegistryEntry.cpp.

00300                                                                                               {
00301   if ( 0 != key )  {
00302     if ( key == m_pObject )    {
00303       return const_cast<RegistryEntry*>(this);
00304     }
00305     // Look in the immediate level:
00306     RegistryEntry *result = CAST_REGENTRY(RegistryEntry*, i_find(key->registry()));
00307     if ( 0 != result ) return result;
00308     // Go levels down
00309     for (Store::const_iterator i = m_store.begin(); i != m_store.end(); i++ )   {
00310       try   {
00311         const RegistryEntry *entry = CAST_REGENTRY(RegistryEntry*, *i);
00312         if( 0 != (result = entry->i_find(key)) ) 
00313           return result;
00314       }
00315       catch ( ... )   {    }
00316     }
00317   }
00318   return 0;
00319 }

DataSvcHelpers::RegistryEntry * DataSvcHelpers::RegistryEntry::i_add ( const std::string name  )  [private]

Internal method to add entries.

Definition at line 179 of file RegistryEntry.cpp.

00179                                                                                        {
00180   if ( nam[0] != SEPARATOR )   {
00181     std::string path = nam;
00182     path.insert(path.begin(), SEPARATOR);
00183     return i_add(path);
00184   }
00185   // if this object is already present, this is an error....
00186   for (Store::iterator i = m_store.begin(); i != m_store.end(); i++ )   {
00187     if ( nam == (*i)->name() )  {
00188       return 0;
00189     }
00190   }
00191   return new RegistryEntry( nam, this );
00192 }

void DataSvcHelpers::RegistryEntry::setParent ( RegistryEntry pParent  )  [private]

Set new parent pointer.

Definition at line 88 of file RegistryEntry.cpp.

00088                                                                      {
00089   m_pParent = pParent;
00090   m_fullpath = "";
00091   assemblePath(m_fullpath);
00092 }

void DataSvcHelpers::RegistryEntry::setDataSvc ( IDataProviderSvc s  )  [inline, private]

Set the transient data store.

Definition at line 81 of file RegistryEntry.h.

00081                                             {
00082       m_pDataProviderSvc = s;
00083     }

virtual RegistryEntry* DataSvcHelpers::RegistryEntry::parentEntry (  )  [inline, private, virtual]

Pointer to parent registry entry.

Definition at line 85 of file RegistryEntry.h.

00085                                            {
00086       return m_pParent;
00087     }

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.

00089                                                              {
00090       return i_find(path);
00091     }

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.

00093                                                            {
00094       return i_find(key);
00095     }

void DataSvcHelpers::RegistryEntry::makeHard ( DataObject pObject  )  [private]

Initialize link as hard link.

Create hard link.

Definition at line 110 of file RegistryEntry.cpp.

00110                                                                 {
00111   makeSoft(pObject);
00112   m_isSoft = false;
00113   if ( 0 != m_pObject )   {
00114     m_pObject->setRegistry(this);
00115   }
00116   if ( 0 != m_pAddress )   {
00117     m_pAddress->setRegistry(this);
00118   }
00119 }

void DataSvcHelpers::RegistryEntry::makeHard ( IOpaqueAddress pAddress  )  [private]

Initialize link as hard link.

Create hard link.

Definition at line 122 of file RegistryEntry.cpp.

00122                                                                      {
00123   m_isSoft = false;
00124   setAddress(pAddress);
00125 }

void DataSvcHelpers::RegistryEntry::makeSoft ( DataObject pObject  )  [private]

Initialize link as soft link.

Create soft link.

Definition at line 95 of file RegistryEntry.cpp.

00095                                                                 {
00096   m_isSoft = true;
00097   setObject(pObject);
00098 //  if ( 0 != m_pObject )   { // Useless: This justs sets my own address again...
00099 //    setAddress(m_pObject->address());
00100 //  }
00101 }

void DataSvcHelpers::RegistryEntry::makeSoft ( IOpaqueAddress pAddress  )  [private]

Initialize link as soft link.

Create soft link.

Definition at line 104 of file RegistryEntry.cpp.

00104                                                                      {
00105   m_isSoft = true;
00106   setAddress(pAddress);
00107 }

unsigned long DataSvcHelpers::RegistryEntry::release (  )  [virtual]

IInterface implementation: Reference the object.

Release entry.

Implements IRegistry.

Definition at line 79 of file RegistryEntry.cpp.

00079                                                     {
00080   unsigned long cnt = --m_refCount;
00081   if ( 0 == m_refCount )   {
00082     delete this;
00083   }
00084   return cnt;
00085 }

virtual unsigned long DataSvcHelpers::RegistryEntry::addRef (  )  [inline, virtual]

IInterface implementation: Dereference the object.

Implements IRegistry.

Definition at line 112 of file RegistryEntry.h.

00112                                       {
00113       return ++m_refCount;
00114     }

const std::string& DataSvcHelpers::RegistryEntry::name (  )  const [inline, virtual]

Retrieve name of the entry.

Implements IRegistry.

Definition at line 116 of file RegistryEntry.h.

00116                                     {
00117       return m_path;
00118     }

virtual const std::string& DataSvcHelpers::RegistryEntry::identifier (  )  const [inline, virtual]

Full identifier (or key).

Implements IRegistry.

Definition at line 120 of file RegistryEntry.h.

00120                                                    {
00121       return m_fullpath;
00122     }

virtual IDataProviderSvc* DataSvcHelpers::RegistryEntry::dataSvc (  )  const [inline, virtual]

Retrieve pointer to Transient Store.

Implements IRegistry.

Definition at line 124 of file RegistryEntry.h.

00124                                                {
00125       return m_pDataProviderSvc;
00126     }

virtual DataObject* DataSvcHelpers::RegistryEntry::object (  )  const [inline, virtual]

Retrive object behind the link.

Implements IRegistry.

Definition at line 128 of file RegistryEntry.h.

00128                                             {
00129       return m_pObject;
00130     }

virtual IOpaqueAddress* DataSvcHelpers::RegistryEntry::address (  )  const [inline, virtual]

Retrieve opaque storage address.

Implements IRegistry.

Definition at line 132 of file RegistryEntry.h.

00132                                                {
00133       return m_pAddress;
00134     }

virtual IRegistry* DataSvcHelpers::RegistryEntry::parent (  )  const [inline, virtual]

Pointer to parent directory entry.

Definition at line 136 of file RegistryEntry.h.

00136                                          {
00137       return m_pParent;
00138     }

virtual bool DataSvcHelpers::RegistryEntry::isSoft (  )  const [inline, virtual]

Is the link soft or hard.

Definition at line 140 of file RegistryEntry.h.

00140                                       {
00141       return m_isSoft;
00142     }

const Store& DataSvcHelpers::RegistryEntry::leaves (  )  const [inline]

Access the leaves of the object.

Definition at line 144 of file RegistryEntry.h.

00144                                    {
00145       return m_store;
00146     }

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.

00148                                             {
00149       return m_store.size();
00150     }

virtual bool DataSvcHelpers::RegistryEntry::isEmpty (  )  const [inline, virtual]

Simple check if the Container is empty.

Definition at line 152 of file RegistryEntry.h.

00152                                                 {
00153       return m_store.size() == 0;
00154     }

virtual Iterator DataSvcHelpers::RegistryEntry::begin ( void   )  const [inline, virtual]

Return starting point for container iteration.

Definition at line 156 of file RegistryEntry.h.

00156                                            {
00157       return m_store.begin();
00158     }

virtual Iterator DataSvcHelpers::RegistryEntry::end ( void   )  const [inline, virtual]

Return end elemtn if the container.

Definition at line 160 of file RegistryEntry.h.

00160                                            {
00161       return m_store.end();
00162     }

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.

00164                                                              {
00165       return i_find(obj);
00166     }

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.

00168                                                               {
00169       return i_find(path);
00170     }

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.

00128                                                                           {
00129   if ( 0 != pAddress  )   {
00130     pAddress->addRef();
00131     pAddress->setRegistry(this);
00132   }
00133   if ( 0 != m_pAddress ) m_pAddress->release();
00134   m_pAddress = pAddress;
00135 }

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.

00138                                                                    {
00139   if ( 0 != pObject  )  {
00140     pObject->addRef();
00141     if ( !isSoft() ) pObject->setRegistry(this);
00142   }
00143   if ( 0 != m_pObject ) m_pObject->release();
00144   m_pObject = pObject;
00145 }

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.

00211                                                                                                   {
00212   RegistryEntry* entry = i_add(name);
00213   if ( 0 != entry )   {
00214     ( is_soft ) ? entry->makeSoft(pObject) : entry->makeHard(pObject);
00215     add( entry );
00216     return StatusCode::SUCCESS;
00217   }
00218   return StatusCode::FAILURE;
00219 }

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.

00222                                                                                                        {
00223   RegistryEntry* entry = i_add(name);
00224   if ( 0 != entry )   {
00225     ( is_soft ) ? entry->makeSoft(pAddress) : entry->makeHard(pAddress);
00226     add( entry );
00227     return StatusCode::SUCCESS;
00228   }
00229   return StatusCode::FAILURE;
00230 }

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.

00162                                                                  {
00163   if ( nam[0] != SEPARATOR )   {
00164     std::string path = nam;
00165     path.insert(path.begin(), SEPARATOR);
00166     return remove(path);
00167   }
00168   // if this object is already present, this is an error....
00169   for (Store::iterator i = m_store.begin(); i != m_store.end(); i++ )   {
00170     if ( nam == (*i)->name() )   {
00171       remove(*i);
00172       return StatusCode::SUCCESS;
00173     }
00174   }
00175   return StatusCode::FAILURE;
00176 }

long DataSvcHelpers::RegistryEntry::add ( IRegistry obj  )  [virtual]

Add object to the container.

Definition at line 195 of file RegistryEntry.cpp.

00195                                                          {
00196   try   {
00197     RegistryEntry* pEntry = CAST_REGENTRY(RegistryEntry*, obj);
00198     pEntry->setDataSvc(m_pDataProviderSvc);
00199     m_store.push_back(pEntry);
00200     pEntry->setParent(this);
00201     if ( !pEntry->isSoft() && pEntry->address() != 0 )   {
00202       pEntry->address()->setRegistry(pEntry);
00203     }
00204   }
00205   catch ( ... )   {
00206   }
00207   return m_store.size();
00208 }

long DataSvcHelpers::RegistryEntry::remove ( IRegistry obj  )  [virtual]

Remove an object from the container.

Definition at line 148 of file RegistryEntry.cpp.

00148                                                               {
00149   try   {
00150     RegistryEntry* pEntry = dynamic_cast<RegistryEntry*>(obj);
00151     Store::iterator i = std::remove(m_store.begin(), m_store.end(), pEntry);
00152     if (i != m_store.end())   {
00153       pEntry->release();
00154       m_store.erase( i, m_store.end() );
00155     }
00156   }
00157   catch ( ... )   {     }
00158   return m_store.size();
00159 }

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.

00233                                                    {
00234   for (Store::iterator i = m_store.begin(); i != m_store.end(); i++ )   {
00235     RegistryEntry* entry = CAST_REGENTRY(RegistryEntry*, *i);
00236     if ( 0 != entry )   {
00237       entry->deleteElements();
00238       entry->release();
00239     }
00240   }
00241   m_store.erase(m_store.begin(), m_store.end());
00242   return 0;
00243 }

long DataSvcHelpers::RegistryEntry::traverseTree ( IDataStoreAgent pAgent,
int  level = 0 
) [virtual]

traverse data tree

Definition at line 322 of file RegistryEntry.cpp.

00322                                                                                     {
00323   bool go_down = pAgent->analyse(this, level);
00324   long status = StatusCode::SUCCESS;
00325   if ( go_down )    {
00326     for ( Store::iterator i = m_store.begin(); i != m_store.end(); i++ )   {
00327       try   {
00328         RegistryEntry* entry = CAST_REGENTRY(RegistryEntry*, *i);
00329         entry->traverseTree(pAgent, level+1);
00330       }
00331       catch (...)   {
00332         status = StatusCode::FAILURE;
00333       }
00334     }
00335   }
00336   return status;
00337 }


Friends And Related Function Documentation

friend class ::DataSvc [friend]

Definition at line 39 of file RegistryEntry.h.


Member Data Documentation

Reference counter.

Definition at line 44 of file RegistryEntry.h.

Is the link soft or hard?

Definition at line 46 of file RegistryEntry.h.

String containing full path of the object (volatile).

Definition at line 48 of file RegistryEntry.h.

Path name.

Definition at line 50 of file RegistryEntry.h.

Pointer to parent.

Definition at line 52 of file RegistryEntry.h.

Pointer to opaque address (load info).

Definition at line 54 of file RegistryEntry.h.

Pointer to object.

Definition at line 56 of file RegistryEntry.h.

Pointer to hosting transient store.

Definition at line 58 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:

Generated at Wed Mar 17 18:21:10 2010 for Gaudi Framework, version v21r8 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004