gatelib  2.1
g_cont_vect.h
1 #pragma once
2 
3 #include "g_cont_vect_base.h"
4 #include "private/g_cont_vect_priv.h"
5 #include "g_cont_ref_custom.h"
6 #include "g_cont_it.h"
7 #include <string.h>
8 
9 
10 namespace g
11 {
12 namespace cont
13 {
14 
15 template < class T , class IT=it<T>, class IT_C=it_const<T> > class vect : public vect_base<T,T,const T,IT,IT_C>
16 {
17 public:
18  template <typename> friend class priv::vect_positioner;
19  template <typename> friend struct priv::vect_content;
20 
22  typedef IT It_t;
23  typedef IT_C ItConst_t;
25 
26  vect ( AllocationPolicyAbstract* ap = AllocationPolicyAbstract::get_FromStandardPolicy() , int aAllocDeltaRBits = G_VECT_AL_DELTA_MASK_BITS ) : Base_t ( ap ,aAllocDeltaRBits ){}
27  vect ( const T* v, int lbound , int ubound , AllocationPolicyAbstract* ap = AllocationPolicyAbstract::get_FromStandardPolicy() , int aAllocDeltaRBits = G_VECT_AL_DELTA_MASK_BITS):Base_t ( ap ,aAllocDeltaRBits ){ setContentFromVector (v,lbound,ubound); }
28  vect ( const T* v , size_t s , AllocationPolicyAbstract* ap = AllocationPolicyAbstract::get_FromStandardPolicy() , int aAllocDeltaRBits = G_VECT_AL_DELTA_MASK_BITS ) : Base_t ( ap ,aAllocDeltaRBits ){ setContentFromVector (v,s); }
29  vect ( const vect& o , AllocationPolicyAbstract* ap = AllocationPolicyAbstract::get_FromStandardPolicy() , int aAllocDeltaRBits = G_VECT_AL_DELTA_MASK_BITS ): Base_t ( ap ,aAllocDeltaRBits ) { this->mContent.replaceContent ( o.getLbound ( ) , o.getUbound ( ) , o.mContent.data ); }
30 
31  virtual ~vect ( ){}
32 
33  vect& operator = ( const vect& other ) { setContent ( other ); return *this; }
34 
35  //Copy the content of other value_base_cont and delete any previous content
36  virtual void setContent ( const vect& other ){ this->mContent.replaceContent ( other.getLbound(), other.getUbound() , (const T*)other ); }
37 
38  void setContentFromVector ( const T* v , size_t size ) { setContentFromVector ( v , 0 , (int)size-1 ); }
39  void setContentFromVector ( const T* v , int lbound , int ubound ) { this->mContent.replaceContent ( lbound , ubound , v ); }
40 
41  operator const T* ( ) const { return this->mContent.data; }
42  operator T* ( ) { return this->mContent.data; }
43 
44  class Ref : public ref_custom< vect<T,IT,IT_C> >
45  {
46  public:
47  Ref(){}
48  Ref(const Ref& other ){ G_VERBOSE_MSG_L5("vect::Ref::Ref(Ref& other )"); this->mRefTake(other); }
49 
50  typedef vect<T,IT,IT_C> Vect_t;
51 
52  Vect_t& operator *() { G_VERBOSE_MSG_L5("T& vect::Ref::operator *()"); return *this->mGetObjP(); }
53  Vect_t* operator ->() { G_VERBOSE_MSG_L5("T& vect::Ref::operator ->()");return this->mGetObjP(); }
54  const Vect_t& operator *() const { G_VERBOSE_MSG_L5("const T& vect::Ref::operator *()");return *this->mGetObjP(); }
55  const Vect_t* operator ->() const { G_VERBOSE_MSG_L5("const T* vect::Ref::operator ->()");return this->mGetObjP(); }
56 
57  Ref& operator = ( const Ref& other ) { this->mRefTake(*this); return *this; }
58 
59  static Ref g_cont_new ( AllocationPolicyAbstract* aAllocPolicyP = AllocationPolicyAbstract::get_FromStandardPolicy ( ) , int aAllocDeltaRBits = G_VECT_AL_DELTA_MASK_BITS )
60  {
61  Ref result;
62 
63  new ( result.mAllocateMemForObject(aAllocPolicyP) )vect<T,IT,IT_C>(aAllocPolicyP,aAllocDeltaRBits);
64  result.mIncRef ( );
65 
66  return result;
67  }
68  };
69 };
70 
71 }//namespace cont
72 }//namespace g
73 
Definition: g_cont_ref_base.h:37
Definition: g_cont_AllocationPolicyAbstract.h:16
Definition: g.mthread.ThreadSimpleEvent.h:5
Definition: g_cont_it_ref.h:11
Definition: g_cont_vect.h:15
Definition: g_cont_vect.h:44
Definition: g_cont_vect_base.h:14
Definition: g_cont_vect_priv.h:24
Definition: g_cont_vect_priv.h:237