00001 00043 #ifndef ABA_IDMAP_H 00044 #define ABA_IDMAP_H 00045 #include <ace/Synch.h> 00046 00047 #include "abacus/abacusroot.h" 00048 #include "abacus/id.h" 00049 00050 class ABA_MASTER; 00051 00052 #ifdef ABACUS_NEW_TEMPLATE_SYNTAX 00053 template <class Type> 00054 class ABA_IDMAP; 00055 00056 template <class Type> 00057 ostream &operator<< (ostream& out, const ABA_IDMAP<Type> &idmap); 00058 #endif 00059 00060 template <class Type> class ABA_IDMAP : public ABA_ABACUSROOT { 00061 public: 00062 00070 ABA_IDMAP(ABA_MASTER *master, int size, int index); 00071 00073 ~ABA_IDMAP(); 00074 #ifdef ABACUS_NEW_TEMPLATE_SYNTAX 00075 00083 friend ostream& operator<< <>(ostream& , const ABA_IDMAP<Type> &); 00084 #else 00085 00093 friend ostream& operator<<(ostream& out, const ABA_IDMAP<Type> &idmap); 00094 #endif 00095 00103 Type *find(const ABA_ID &id); 00104 00108 void insert(const ABA_ID &id, const Type *obj); 00109 00118 void insertWithNewId(ABA_ID &id, const Type *obj); 00119 void insertAlias(const ABA_ID &id, const ABA_ID &aliasId); 00120 00126 int remove(const ABA_ID &id); 00127 unsigned long sequence() const; 00128 int proc() const; 00129 int index() const; 00130 00131 private: 00132 ABA_MASTER *master_; 00133 ABA_HASH<ABA_ID, const Type*> map_; 00134 unsigned long sequence_; 00135 int proc_; 00136 int index_; 00137 ACE_Thread_Mutex mp_; 00138 00139 }; 00140 00141 #include "abacus/idmap.inc" 00142 00143 template<class Type> 00144 inline unsigned long ABA_IDMAP<Type>::sequence() const { return sequence_; }; 00145 template<class Type> 00146 inline int ABA_IDMAP<Type>::proc() const { return proc_; }; 00147 template<class Type> 00148 inline int ABA_IDMAP<Type>::index() const { return index_; }; 00149 00150 #endif // !ABA_IDMAP_H 00151