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

CdbBdbSimpleCache.hh

Go to the documentation of this file.
00001 #ifndef CDBBDB_SIMPLE_CACHE_HH
00002 #define CDBBDB_SIMPLE_CACHE_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbBdbSimpleCache.hh,v 1.3 2004/10/21 20:35:52 gapon Exp $
00006 
00007 #include "CdbBdb/CdbBdbCache.hh"
00008 
00009 #include <oo.h>
00010 
00011 #include <string>
00012 #include <map>
00013 
00014 /// A simple implementation of the interface to the caching facility
00015 /**
00016   * This class provides a cache implementation based on std::map for
00017   * persistent object references of ooRef(ooObj) type.
00018   *
00019   * @see class CdbBdbCache
00020   */
00021 class CdbBdbSimpleCache : public CdbBdbCache< ooRef(ooObj) > {
00022 
00023 public:
00024 
00025   /// Default constructor
00026 
00027     CdbBdbSimpleCache( );
00028 
00029   /// Destructor
00030 
00031     virtual ~CdbBdbSimpleCache( );
00032 
00033   /// Add a new element to the cache
00034   /**
00035     * Implements the corresponding method at the base class.
00036     *
00037     * @see CdbBdbCache::addObject()
00038     */
00039     virtual void addObject( const ooRef(ooObj)& theKeyRef,
00040                             const ooRef(ooObj)& theValueRef );
00041 
00042   /// Find an object at the cache
00043   /**
00044     * Implements the corresponding method at the base class.
00045     *
00046     * @see CdbBdbCache::findObject()
00047     */
00048     virtual ooRef(ooObj) findObject( const ooRef(ooObj)& theKeyRef ) const;
00049 
00050   /// Create an iterator for keys stored at the cache
00051   /**
00052     * Implements the corresponding method at the base class.
00053     *
00054     * @see CdbBdbCache::iterator()
00055     */
00056     virtual CdbItr<ooRef(ooObj)> iterator( ) const;
00057 
00058 public:
00059 
00060   /// Translate an OID into a string
00061   /**
00062     * This method is used to produce dictionary keys from OID-s.
00063     */
00064     static std::string refToString( const ooRef(ooObj)& theRef );
00065 
00066   /// Translate a string into an OID
00067   /**
00068     * This method is used by the iterator of keys to retirn OID-s instead of strings.
00069     */
00070     static ooRef(ooObj) stringToRef( const std::string& theString );
00071 
00072 private:
00073 
00074   // Data members
00075 
00076     std::map<std::string, ooRef(ooObj)>* _dict;
00077 };
00078 
00079 #endif /* CDBBDB_SIMPLE_CACHE_HH */

Generated on Mon Dec 5 18:22:02 2005 for CDB by doxygen1.3-rc3