3 #include "g_cont_cont_with_positioner.h"
4 #include "g_cont_it_ref.h"
6 #include "g_cont_ref.h"
7 #include "g_cont_alg.h"
13 template <
class T ,
class REF ,
class REF_C >
class it_base;
22 template <
class,
class,
class>
friend class it_base;
23 template <
class,
class,
class,
class,
class>
friend class lst_base;
24 template <
class,
class,
class,
class,
class>
friend class vect_base;
27 typedef REF_C RefConst_t;
29 typedef IT_C ItConst_t;
42 bool operator == (
const base_cont& other )
const;
44 virtual Ref_t
remove (
const It_t& ) = 0;
45 virtual void eraseMemory ( ) = 0;
47 virtual void pushAfter (
const Ref_t& ,
const It_t& ) = 0;
48 virtual void pushBefore (
const Ref_t& ,
const It_t& ) = 0;
50 virtual void pushHead (
const Ref_t& aItem ) { this->pushBefore(aItem, It_t(*
this, head)); }
51 virtual void pushTail (
const Ref_t& aItem ) { this->pushAfter(aItem, It_t(*
this, tail)); }
53 virtual Ref_t popHead() {
return this->
remove(It_t(*
this, head)); }
54 virtual Ref_t popTail() {
return this->
remove(It_t(*
this, tail)); }
56 virtual RefConst_t getHead()
const {
return ItConst_t(*
this,head).underlying(); }
57 virtual Ref_t getHead() {
return It_t(*
this,head).underlying(); }
59 virtual RefConst_t getTail()
const {
return ItConst_t(*
this,tail).underlying(); }
60 virtual Ref_t getTail() {
return It_t(*
this,tail).underlying(); }
62 virtual It_t getIterator ( IterFrom_t from = head ) {
return It_t(*
this,from); }
63 virtual ItConst_t getIterator ( IterFrom_t from = head )
const {
return ItConst_t(*
this,from); }
65 virtual void setContent (
base_cont& other );
67 bool contains (
const RefConst_t& value )
const {
return search(value).isIn(); }
68 It_t search (
const Ref_t& item ) {
return alg::search ( getIterator(head) , item ); }
69 ItConst_t search (
const RefConst_t& item )
const {
return alg::search ( getIterator(head) , item ); }
70 bool tryRemove (
const Ref_t& item ) {
return alg::try_remove(*
this,item); }
71 size_t removeAll (
const Ref_t& item ) {
return alg::remove_all(*
this,item); }
74 inline int mDeref (
const It_t& where )
const {
return where.mIndex; }
75 inline int mTestIterator(
const It_t& ,
bool exc_if_empty =
false )
const;
76 inline Ref_t* mSequentialGet (
int i )
const;
79 template<
class T,
class REF,
class REF_C ,
class IT ,
class IT_C >
bool base_cont<T,REF,REF_C,IT,IT_C>::operator == (
const base_cont<T,REF,REF_C,IT,IT_C>& aOther )
const
81 ItConst_t my_it(*
this);
83 if ( this->getSize() != aOther.getSize() )
88 for ( ItConst_t oth_it ( aOther ) ; oth_it.isIn ( ) ; oth_it++ , my_it++ )
90 if(my_it.underlying() != oth_it.underlying())
99 template<
class T,
class REF,
class REF_C ,
class IT ,
class IT_C >
100 void base_cont<T,REF,REF_C,IT,IT_C>::setContent ( base_cont<T,REF,REF_C,IT,IT_C>& aOther )
104 for ( It_t it(aOther) ; it.isIn() ; it++ )
106 pushTail ( it.underlying() );
111 template<
class T,
class REF,
class REF_C ,
class IT ,
class IT_C >
int base_cont<T,REF,REF_C,IT,IT_C>::mTestIterator(
const It_t& aWhere ,
bool aRaiseExcIfEmpty )
const
113 G_EXC_SET_CONTEXT (
"int base_cont<T,REF,REF_C,IT,IT_C>::mTestIterator( const It_t& aWhere , bool aRaiseExcIfEmpty ) const" );
116 if (!aWhere.isMine(*
this))
118 G_EXC_RAISE_MSG ( NotAValidIteratorException ,
"Iterator is not belonging to this ref_base_cont." );
121 if ( aWhere.isIn () )
123 return mDeref ( aWhere );
125 else if (this->getSize() > 0)
127 G_EXC_RAISE_MSG(NotAValidIteratorException ,
"Iterator pointer no longer valid(Probably content has changed or reallocated).");
129 else if(aRaiseExcIfEmpty)
134 return G_CONT_INDEX_NOT_VALID;
138 template<
class T,
class REF,
class REF_C ,
class IT ,
class IT_C > REF* base_cont<T,REF,REF_C,IT,IT_C>::mSequentialGet(
int aI)
const
140 G_EXC_SET_CONTEXT (
"REF* base_cont<T,REF,REF_C,IT,IT_C>::mSequentialGet(int aI) const" );
144 G_EXC_RAISE_CONT (
"Index < 0" );
149 int index = this->mPositionerP->first();
151 if ( index != G_CONT_INDEX_NOT_VALID )
153 this->mPositionerP->forward(index,aI);
156 if ( index == G_CONT_INDEX_NOT_VALID )
158 G_EXC_RAISE_CONT(
"Index out of bounds!" );
161 return this->mPositionerP->getPtr ( index );
Definition: g_cont_base_cont.h:19
Definition: g_cont_lst_base.h:12
Definition: g_cont_AllocationPolicyAbstract.h:16
#define G_EXC_DEFINE(aexctypename, abaseexctypename)
Definition: g_exception_macros.h:39
Definition: g.mthread.ThreadSimpleEvent.h:5
#define G_EXC_RAISE_MSG(aexctype, amessage)
Raises an exception specifying the message.
Definition: g_exception_macros.h:58
Definition: g_cont_base_cont.h:13
Definition: g_cont_cont_with_positioner.h:10
Definition: g_cont_vect_base.h:14
#define G_EXC_SET_CONTEXT(acontextstr)
Sets the method context.
Definition: g_exception_macros.h:52