00001
00002 #ifndef _GEMFIRE_VECTORT_HPP_
00003 #define _GEMFIRE_VECTORT_HPP_
00004
00005
00006
00007
00008
00009
00010
00011 #include "gfcpp_globals.hpp"
00012 #include "VectorOfSharedBase.hpp"
00013 #include "Cacheable.hpp"
00014 #include "CacheableKey.hpp"
00015
00019 namespace gemfire {
00020
00022 template < class PTR_TYPE > class VectorT
00023 {
00024 private:
00025 VectorOfSharedBase m_vector;
00026
00027 public:
00028
00030 class Iterator
00031 {
00032 private:
00033
00034 VectorOfSharedBase::Iterator m_iter;
00035
00036
00037 inline Iterator( const VectorOfSharedBase::Iterator& iter )
00038 : m_iter( iter ) { }
00039
00040
00041 Iterator( );
00042
00043
00044 public:
00045
00046 inline const PTR_TYPE operator * ( ) const
00047 {
00048 return staticCast<PTR_TYPE>( *m_iter );
00049 }
00050
00051 inline Iterator& operator ++ ( )
00052 {
00053 ++m_iter;
00054 return *this;
00055 }
00056
00057 inline void operator ++ ( int )
00058 {
00059 m_iter++;
00060 }
00061
00062 inline bool operator == ( const Iterator& other ) const
00063 {
00064 return ( m_iter == other.m_iter );
00065 }
00066
00067 inline bool operator != ( const Iterator& other ) const
00068 {
00069 return ( m_iter != other.m_iter );
00070 }
00071
00072
00073 friend class VectorT;
00074 };
00075
00077 inline size_t size( ) const
00078 {
00079 return m_vector.size();
00080 }
00081
00083 inline size_t length( ) const
00084 {
00085 return m_vector.size();
00086 }
00087
00089 inline size_t max_size( ) const
00090 {
00091 return m_vector.max_size();
00092 }
00093
00095 inline size_t capacity( ) const
00096 {
00097 return m_vector.capacity();
00098 }
00099
00101 inline bool empty( ) const
00102 {
00103 return m_vector.empty();
00104 }
00105
00107 inline PTR_TYPE operator [] ( size_t n )
00108 {
00109 return staticCast<PTR_TYPE>( m_vector[n] );
00110 }
00111
00113 inline const PTR_TYPE operator [] ( size_t n ) const
00114 {
00115 return staticCast<PTR_TYPE>( m_vector[n] );
00116 }
00117
00119 inline PTR_TYPE at( size_t n )
00120 {
00121 return staticCast<PTR_TYPE>( m_vector.at( n ) );
00122 }
00123
00125 inline const PTR_TYPE at( size_t n ) const
00126 {
00127 return staticCast<PTR_TYPE>( m_vector.at( n ) );
00128 }
00129
00131 inline Iterator begin( ) const
00132 {
00133 return Iterator( m_vector.begin( ) );
00134 }
00135
00137 inline Iterator end( ) const
00138 {
00139 return Iterator( m_vector.end( ) );
00140 }
00141
00143 inline VectorT( )
00144 : m_vector( )
00145 {
00146 }
00147
00149 inline VectorT( size_t n )
00150 : m_vector( n )
00151 {
00152 }
00153
00155 inline VectorT( size_t n, const PTR_TYPE& t )
00156 : m_vector( n, t )
00157 {
00158 }
00159
00161 inline VectorT( const VectorT& other )
00162 : m_vector( other.m_vector )
00163 {
00164 }
00165
00167 inline ~VectorT( )
00168 {
00169
00170 }
00171
00173 inline VectorT& operator = ( const VectorT& other )
00174 {
00175 m_vector = other.m_vector;
00176 return *this;
00177 }
00178
00180 inline void reserve( size_t n )
00181 {
00182 m_vector.reserve( n );
00183 }
00184
00186 inline PTR_TYPE front( )
00187 {
00188 return staticCast<PTR_TYPE>( m_vector.front( ) );
00189 }
00190
00192 inline const PTR_TYPE front( ) const
00193 {
00194 return staticCast<PTR_TYPE>( m_vector.front( ) );
00195 }
00196
00198 inline PTR_TYPE back( )
00199 {
00200 return staticCast<PTR_TYPE>( m_vector.back( ) );
00201 }
00202
00204 inline const PTR_TYPE back( ) const
00205 {
00206 return staticCast<PTR_TYPE>( m_vector.back( ) );
00207 }
00208
00210 inline void push_back( const PTR_TYPE& e )
00211 {
00212 m_vector.push_back( e );
00213 }
00214
00216 inline void pop_back( )
00217 {
00218 m_vector.pop_back();
00219 }
00220
00222 inline void swap( VectorT& other )
00223 {
00224 m_vector.swap( other.m_vector );
00225 }
00226
00228 inline void clear( )
00229 {
00230 m_vector.clear();
00231 }
00232
00236 inline void resize( size_t n, const PTR_TYPE& t = NULL )
00237 {
00238 m_vector.resize( n, t );
00239 }
00240
00242 inline void insert( size_t index, const PTR_TYPE& t )
00243 {
00244 m_vector.insert( index, t );
00245 }
00246
00248 inline void erase( size_t index )
00249 {
00250 m_vector.erase( index );
00251 }
00252
00253 };
00254
00255 typedef VectorT<CacheablePtr> _VectorOfCacheable;
00256 typedef VectorT<CacheableKeyPtr> _VectorOfCacheableKey;
00257 typedef VectorT<RegionEntryPtr> VectorOfRegionEntry;
00258 typedef VectorT<RegionPtr> VectorOfRegion;
00259
00264 class CPPCACHE_EXPORT VectorOfCacheable :
00265 public _VectorOfCacheable, public SharedBase
00266 {
00267 public:
00269 typedef _VectorOfCacheable::Iterator Iterator;
00270
00272 inline VectorOfCacheable() :
00273 _VectorOfCacheable() { }
00274
00276 inline VectorOfCacheable(size_t n) :
00277 _VectorOfCacheable(n) { }
00278
00280 inline VectorOfCacheable(size_t n, const CacheablePtr& t ) :
00281 _VectorOfCacheable(n, t) { }
00282
00284 inline VectorOfCacheable(const VectorOfCacheable& other) :
00285 _VectorOfCacheable(other) { }
00286 };
00287
00292 class CPPCACHE_EXPORT VectorOfCacheableKey :
00293 public _VectorOfCacheableKey, public SharedBase
00294 {
00295 public:
00297 typedef _VectorOfCacheableKey::Iterator Iterator;
00298
00300 inline VectorOfCacheableKey() :
00301 _VectorOfCacheableKey() { }
00302
00304 inline VectorOfCacheableKey(size_t n) :
00305 _VectorOfCacheableKey(n) { }
00306
00308 inline VectorOfCacheableKey(size_t n, const CacheableKeyPtr& t ) :
00309 _VectorOfCacheableKey(n, t) { }
00310
00312 inline VectorOfCacheableKey(const VectorOfCacheableKey& other) :
00313 _VectorOfCacheableKey(other) { }
00314 };
00315
00316 typedef SharedPtr<VectorOfCacheable> VectorOfCacheablePtr;
00317 typedef SharedPtr<VectorOfCacheableKey> VectorOfCacheableKeyPtr;
00318
00319 }
00320
00321 #endif