build-artifacts/win/product/include/gfcpp/VectorT.hpp

Go to the documentation of this file.
00001 
00002 #ifndef _GEMFIRE_VECTORT_HPP_
00003 #define _GEMFIRE_VECTORT_HPP_
00004 
00005 /*=========================================================================
00006  * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
00007  * This product is protected by U.S. and international copyright
00008  * and intellectual property laws. Pivotal products are covered by
00009  * more patents listed at http://www.pivotal.io/patents.
00010  *========================================================================
00011  */
00012 
00013 #include "gfcpp_globals.hpp"
00014 #include "VectorOfSharedBase.hpp"
00015 #include "Cacheable.hpp"
00016 #include "CacheableKey.hpp"
00017 
00021 namespace gemfire {
00022 
00024 template < class PTR_TYPE > class VectorT
00025 {
00026   private:
00027     VectorOfSharedBase m_vector;
00028 
00029   public:
00030 
00032     class Iterator
00033     {
00034       private:
00035 
00036         VectorOfSharedBase::Iterator m_iter;
00037 
00038 
00039         inline Iterator( const VectorOfSharedBase::Iterator& iter )
00040           : m_iter( iter ) { }
00041 
00042         // Never defined.
00043         Iterator( );
00044 
00045 
00046       public:
00047 
00048         inline const PTR_TYPE operator * ( ) const
00049         {
00050           return staticCast<PTR_TYPE>( *m_iter );
00051         }
00052 
00053         inline Iterator& operator ++ ( )
00054         {
00055           ++m_iter;
00056           return *this;
00057         }
00058 
00059         inline void operator ++ ( int )
00060         {
00061           m_iter++;
00062         }
00063 
00064         inline bool operator == ( const Iterator& other ) const
00065         {
00066           return ( m_iter == other.m_iter );
00067         }
00068 
00069         inline bool operator != ( const Iterator& other ) const
00070         {
00071           return ( m_iter != other.m_iter );
00072         }
00073 
00074 
00075         friend class VectorT;
00076     };
00077 
00079     inline int32_t size( ) const
00080     {
00081       return static_cast<int32_t> (m_vector.size());
00082     }
00083 
00085     inline int32_t length( ) const
00086     {
00087       return static_cast<int32_t> (m_vector.size());
00088     }
00089 
00091     inline int32_t max_size( ) const
00092     {
00093       return static_cast<int32_t> (m_vector.max_size());
00094     }
00095 
00097     inline int32_t capacity( ) const
00098     {
00099       return static_cast<int32_t> (m_vector.capacity());
00100     }
00101 
00103     inline bool empty( ) const
00104     {
00105       return m_vector.empty();
00106     }
00107 
00109     inline PTR_TYPE operator [] ( int32_t n )
00110     {
00111       return staticCast<PTR_TYPE>( m_vector[n] );
00112     }
00113 
00115     inline const PTR_TYPE operator [] ( int32_t n ) const
00116     {
00117       return staticCast<PTR_TYPE>( m_vector[n] );
00118     }
00119 
00121     inline PTR_TYPE at( int32_t n )
00122     {
00123       return staticCast<PTR_TYPE>( m_vector.at( n ) );
00124     }
00125 
00127     inline const PTR_TYPE at( int32_t n ) const
00128     {
00129       return staticCast<PTR_TYPE>( m_vector.at( n ) );
00130     }
00131 
00133     inline Iterator begin( ) const
00134     {
00135       return Iterator( m_vector.begin( ) );
00136     }
00137 
00139     inline Iterator end( ) const
00140     {
00141       return Iterator( m_vector.end( ) );
00142     }
00143 
00145     inline VectorT( )
00146     : m_vector( )
00147     {
00148     }
00149 
00151     inline VectorT( int32_t n )
00152     : m_vector( n )
00153     {
00154     }
00155 
00157     inline VectorT( int32_t n, const PTR_TYPE& t )
00158     : m_vector( n, t )
00159     {
00160     }
00161 
00163     inline VectorT( const VectorT& other )
00164     : m_vector( other.m_vector )
00165     {
00166     }
00167 
00169     inline ~VectorT( )
00170     {
00171       // destructor of m_vector field does all the work.
00172     }
00173 
00175     inline VectorT& operator = ( const VectorT& other )
00176     {
00177       m_vector = other.m_vector;
00178       return *this;
00179     }
00180 
00182     inline void reserve( int32_t n )
00183     {
00184       m_vector.reserve( n );
00185     }
00186 
00188     inline PTR_TYPE front( )
00189     {
00190       return staticCast<PTR_TYPE>( m_vector.front( ) );
00191     }
00192 
00194     inline const PTR_TYPE front( ) const
00195     {
00196       return staticCast<PTR_TYPE>( m_vector.front( ) );
00197     }
00198 
00200     inline PTR_TYPE back( )
00201     {
00202       return staticCast<PTR_TYPE>( m_vector.back( ) );
00203     }
00204 
00206     inline const PTR_TYPE back( ) const
00207     {
00208       return staticCast<PTR_TYPE>( m_vector.back( ) );
00209     }
00210 
00212     inline void push_back( const PTR_TYPE& e )
00213     {
00214       m_vector.push_back( e );
00215     }
00216 
00218     inline void pop_back( )
00219     {
00220       m_vector.pop_back();
00221     }
00222 
00224     inline void swap( VectorT& other )
00225     {
00226       m_vector.swap( other.m_vector );
00227     }
00228 
00230     inline void clear( )
00231     {
00232       m_vector.clear();
00233     }
00234 
00238     inline void resize(int32_t n, const PTR_TYPE& t = NULLPTR)
00239     {
00240       m_vector.resize( n, t );
00241     }
00242 
00244     inline void insert( int32_t index, const PTR_TYPE& t )
00245     {
00246       m_vector.insert( index, t );
00247     }
00248 
00250     inline void erase( int32_t index )
00251     {
00252       m_vector.erase( index );
00253     }
00254 
00255 };
00256 
00257 typedef VectorT<CacheablePtr> _VectorOfCacheable;
00258 typedef VectorT<CacheableKeyPtr> _VectorOfCacheableKey;
00259 typedef VectorT<RegionEntryPtr> VectorOfRegionEntry;
00260 typedef VectorT<RegionPtr> VectorOfRegion;
00261 typedef VectorT<CacheableStringPtr> VectorOfCacheableString;
00262 typedef VectorT< CqListenerPtr > VectorOfCqListener;
00263 typedef VectorT< CqQueryPtr > VectorOfCqQuery;
00264 
00269 class CPPCACHE_EXPORT VectorOfCacheable :
00270   public _VectorOfCacheable, public SharedBase
00271 {
00272 public:
00274   typedef _VectorOfCacheable::Iterator Iterator;
00275 
00277   inline VectorOfCacheable() :
00278     _VectorOfCacheable() { }
00279 
00281   inline VectorOfCacheable(int32_t n) :
00282     _VectorOfCacheable(n) { }
00283 
00285   inline VectorOfCacheable(int32_t n, const CacheablePtr& t ) :
00286     _VectorOfCacheable(n, t) { }
00287 
00289   inline VectorOfCacheable(const VectorOfCacheable& other) :
00290     _VectorOfCacheable(other) { }
00291 
00292 private:
00293   const VectorOfCacheable& operator=( const VectorOfCacheable& );
00294 };
00295 
00300 class CPPCACHE_EXPORT VectorOfCacheableKey :
00301   public _VectorOfCacheableKey, public SharedBase
00302 {
00303 public:
00305   typedef _VectorOfCacheableKey::Iterator Iterator;
00306 
00308   inline VectorOfCacheableKey() :
00309     _VectorOfCacheableKey() { }
00310 
00312   inline VectorOfCacheableKey(int32_t n) :
00313     _VectorOfCacheableKey(n) { }
00314 
00316   inline VectorOfCacheableKey(int32_t n, const CacheableKeyPtr& t ) :
00317     _VectorOfCacheableKey(n, t) { }
00318 
00320   inline VectorOfCacheableKey(const VectorOfCacheableKey& other) :
00321     _VectorOfCacheableKey(other) { }
00322 
00323 private:
00324   const VectorOfCacheableKey& operator=( const VectorOfCacheableKey& );
00325 
00326 };
00327 
00328 typedef SharedPtr<VectorOfCacheable> VectorOfCacheablePtr;
00329 typedef SharedPtr<VectorOfCacheableKey> VectorOfCacheableKeyPtr;
00330 
00331 }
00332 
00333 #endif

GemFire C++ Cache API Documentation