00001 #ifndef _GEMFIRE_HASHMAPOFSHAREDBASE_HPP_ 00002 #define _GEMFIRE_HASHMAPOFSHAREDBASE_HPP_ 00003 00004 00005 /*========================================================================= 00006 * (c) Copyright 2002-2007, GemStone Systems, Inc. All Rights Reserved. 00007 * 1260 NW Waterhouse Ave., Suite 200, Beaverton, OR 97006 00008 *======================================================================== 00009 */ 00010 00011 #include "gfcpp_globals.hpp" 00012 #include "SharedPtr.hpp" 00013 #include "HashFunction.hpp" 00014 #ifdef BUILD_CPPCACHE 00015 #include <hash_map> 00016 #endif 00017 00018 00022 namespace gemfire 00023 { 00024 00025 #ifdef BUILD_CPPCACHE 00026 typedef std::hash_map< SharedBasePtr, SharedBasePtr, 00027 HashSB, EqualToSB > HMofSBP; 00028 typedef HMofSBP::const_iterator HMofSBPIterator; 00029 #else 00030 class HMofSBP; 00031 class HMofSBPIterator; 00032 #endif 00033 00034 00037 class CPPCACHE_EXPORT HashMapOfSharedBase 00038 { 00039 private: 00040 00041 HMofSBP* m_stdHashMap; 00042 00043 // Never defined. 00044 HashMapOfSharedBase( ); 00045 00046 00047 public: 00048 00050 class CPPCACHE_EXPORT Iterator 00051 { 00052 private: 00053 00054 HMofSBPIterator* m_iter; 00055 00056 Iterator( const HMofSBPIterator& iter ); 00057 00058 // Never defined 00059 Iterator( ); 00060 00061 00062 public: 00063 00064 Iterator( const Iterator& other ); 00065 00066 const SharedBasePtr first( ) const; 00067 00068 const SharedBasePtr second( ) const; 00069 00070 Iterator& operator ++ ( ); 00071 00072 void operator ++ ( int ); 00073 00074 bool operator == ( const Iterator& other ) const; 00075 00076 bool operator != ( const Iterator& other ) const; 00077 00078 ~Iterator( ); 00079 00080 00081 friend class HashMapOfSharedBase; 00082 }; 00083 00084 00086 size_t size( ) const; 00087 00089 size_t max_size( ) const; 00090 00092 bool empty( ) const; 00093 00095 size_t bucket_count( ) const; 00096 00098 void resize( size_t n ); 00099 00101 void swap( HashMapOfSharedBase& other ); 00102 00106 bool insert( const SharedBasePtr& k, const SharedBasePtr& v ); 00107 00109 size_t erase( const SharedBasePtr& k ); 00110 00112 void clear( ); 00113 00115 bool contains( const SharedBasePtr& k ) const; 00116 00118 Iterator find( const SharedBasePtr& k ) const; 00119 00121 size_t count( const SharedBasePtr& k ) const; 00122 00126 SharedBasePtr& operator [] ( const SharedBasePtr& k ); 00127 00129 Iterator begin( ) const; 00130 00132 Iterator end( ) const; 00133 00135 HashMapOfSharedBase& operator = ( const HashMapOfSharedBase& other ); 00136 00140 HashMapOfSharedBase( const Hasher h, const EqualTo k ); 00141 00145 HashMapOfSharedBase( size_t n, const Hasher h, const EqualTo k ); 00146 00148 HashMapOfSharedBase( const HashMapOfSharedBase& other ); 00149 00151 ~HashMapOfSharedBase( ); 00152 }; 00153 00154 } 00155 00156 00157 #endif