Bdb packages | Design docs | Source docs | Guidelines | Recent releases

Search | Site Map .

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/BdbCondRemote/BdbCondRCacheNode.hh

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // File and Version Information:
00004 //      $Id: BdbCondRCacheNode.hh,v 1.3 2002/06/21 18:49:54 ryd Exp $
00005 //
00006 // Description:
00007 //      This class provides a basic functionality for the node in
00008 //      a heterogenious cache tree.
00009 //      The nodes are able to store the pointers to objects of a user
00010 //      defined class. These objects are given unique keys, represented
00011 //      as RW strings.
00012 //
00013 //      The instances of this class could not be constructed on its own.
00014 //      They must always be used as a base for the actual nodes.
00015 //
00016 //      The methods of this class are defined as "virtual" in order
00017 //      to be able to extend their functionality when it's needed.
00018 //
00019 // Environment:
00020 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00021 //
00022 // Author List:
00023 //      Igor A. Gaponenko       Original Author
00024 //
00025 // Copyright Information:
00026 //      Copyright (C) 2000      Lawrence Berkeley Laboratory
00027 //
00028 //-----------------------------------------------------------------------------
00029 
00030 #ifndef BDBCONDRCACHENODE_HH
00031 #define BDBCONDRCACHENODE_HH
00032 
00033 // -------------------
00034 // -- BaBar Headers --
00035 // -------------------
00036 
00037 #include "BaBar/BaBar.hh"
00038 
00039 //-------------------------------
00040 // Collaborating Class Headers --
00041 //-------------------------------
00042 
00043 #include <string>
00044 #include <vector>
00045 #include <map>
00046 
00047 // ---------------------
00048 // -- Class Interface --
00049 // ---------------------
00050 
00051 template < class Object >
00052 class BdbCondRCacheNode {
00053 
00054 // The ctors, dtor and asignment operator
00055 // are only allowed for the subclasses.
00056 
00057 protected:
00058 
00059   // Constructor(s).
00060 
00061     BdbCondRCacheNode( );
00062 
00063     BdbCondRCacheNode( const BdbCondRCacheNode<Object>& theNode );
00064 
00065   // Destructor
00066 
00067     virtual ~BdbCondRCacheNode( );
00068 
00069   // Operators
00070 
00071     BdbCondRCacheNode& operator=( const BdbCondRCacheNode<Object>& theNode );
00072 
00073 public:
00074 
00075   // Operations
00076 
00077   /** Get a list of keys for the object pointers in the cache.
00078    **
00079    ** The list is always cleared before to search the cache contents.
00080    **/
00081     virtual void keys( std::vector<std::string>& theList );
00082 
00083   /** Find a pointer to the object corresponding to the specified key.
00084    **
00085    ** Return null pointer if the key was not found.
00086    **/
00087     virtual Object* find( const char* theKey );
00088 
00089   /** Add a next object pointer associated with specified key.
00090    **
00091    ** Replace the object pointer and return the previous pointer if there
00092    ** object pointer with the same key and if its pointer is different.
00093    **
00094    ** Return null pointer if the key was not known before.
00095    **/
00096     virtual Object* add( const char* theKey,
00097                          Object*     theObjectPtr );
00098 
00099   /** Remove the object pointer associated with specified key from the cache.
00100    **
00101    ** This is  the "deep" operation - it will also invoke the destructor of
00102    ** the corresponding object (if any) following its pointer.
00103    **/
00104     virtual void remove( const char* theKey );
00105 
00106   /** Remove all object pointers from the cache.
00107    **
00108    ** This will also invoke the destructors for the corresponding objects
00109    ** following their pointers.
00110    **/
00111     virtual void clear( );
00112 
00113 private:
00114 
00115   // Helpers
00116 
00117   /** Invoke the destructors for all the objects whose pointers
00118    ** are stored in the cache. Then clear the cache itself.
00119    **/
00120     void deleteObjects( );
00121 
00122 private:
00123 
00124   // The cache itself.
00125 
00126   std::map<std::string, Object*>* _cache;
00127 };
00128 
00129 #ifdef    BABAR_COMP_INST
00130 #include  "BdbCondRemote/BdbCondRCacheNode.cc"
00131 #endif  /* BABAR_COMP_INST */
00132 
00133 #endif /* BDBCONDRCACHENODE_HH */

 


BaBar Public Site | SLAC | News | Links | Who's Who | Contact Us

Page Owner: Jacek Becla
Last Update: October 04, 2002