00001
00029 #ifndef ABA_POOL_INC
00030 #define ABA_POOL_INC
00031
00032 #include "abacus/pool.h"
00033 #include "abacus/poolslot.h"
00034 #include "abacus/master.h"
00035
00036 #ifdef ABACUS_PARALLEL
00037 #include "abacus/idmap.h"
00038 #endif
00039
00040 template<class BaseType, class CoType>
00041 inline ABA_POOL<BaseType, CoType>::ABA_POOL(ABA_MASTER *master)
00042 :
00043 master_(master),
00044 number_(0)
00045 {
00046 #ifdef ABACUS_PARALLEL
00047 index_ = master_->parmaster()->registerPool(this);
00048 identificationMap_ = new
00049 ABA_IDMAP<ABA_POOLSLOT<BaseType, CoType> >(master, 1000, index_);
00050 #endif
00051 }
00052
00053 template<class BaseType, class CoType>
00054 inline ABA_POOL<BaseType, CoType>::~ABA_POOL()
00055 {
00056 #ifdef ABACUS_PARALLEL
00057 delete identificationMap_;
00058 master_->parmaster()->unregisterPool(index_);
00059 #endif
00060 }
00061
00062 template<class BaseType, class CoType>
00063 void ABA_POOL<BaseType, CoType>::removeConVar(ABA_POOLSLOT<BaseType, CoType> *slot)
00064 {
00065 if (softDeleteConVar(slot)) {
00066 ABA_POOL<BaseType, CoType>::master_->err() << "removeConVar(): removing constraint from slot failed" << endl;
00067 exit (Fatal);
00068 }
00069 }
00070
00071 template<class BaseType, class CoType>
00072 int ABA_POOL<BaseType, CoType>::softDeleteConVar(
00073 ABA_POOLSLOT<BaseType, CoType> *slot)
00074 {
00075 if (slot->softDelete() == 0) {
00076 putSlot(slot);
00077 --number_;
00078 return 0;
00079 }
00080 else return 1;
00081 }
00082
00083 template<class BaseType, class CoType>
00084 void ABA_POOL<BaseType, CoType>::hardDeleteConVar(ABA_POOLSLOT<BaseType, CoType>
00085 *slot)
00086 {
00087 --number_;
00088 slot->hardDelete();
00089 putSlot(slot);
00090 }
00091
00092 template<class BaseType, class CoType>
00093 inline int ABA_POOL<BaseType, CoType>::number() const
00094 {
00095 return number_;
00096 }
00097
00098
00099 #ifdef ABACUS_PARALLEL
00100
00101 template<class BaseType, class CoType>
00102 ABA_POOLSLOT<BaseType, CoType> *ABA_POOL<BaseType, CoType>::findSlot(const ABA_ID &id) const
00103 {
00104 return identificationMap_->find(id);
00105 }
00106
00107 template<class BaseType, class CoType>
00108 ABA_IDMAP<ABA_POOLSLOT<BaseType, CoType> > *
00109 ABA_POOL<BaseType, CoType>::identificationMap() const
00110 {
00111 return identificationMap_;
00112 }
00113
00114 #endif
00115
00116 #endif // ABA_POOL_INC