ProtoDatabase.hGo to the documentation of this file.00001
00002
00003 #ifndef _PROTO_DATABASE_H
00004 #define _PROTO_DATABASE_H
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "TypedBaseMap.h"
00033
00034 template <class S, class T> class ProtoDatabase : public TypedBaseMap<S,T> {
00035 protected:
00036 virtual INLINE Boolean _less(const BMKey &key1, const BMKey &key2) const;
00037
00038
00039 virtual INLINE Boolean _equal(const BMKey &key1, const BMKey &key2) const;
00040
00041
00042 virtual INLINE void _print(ostream &o, const BMKey &key) const;
00043
00044
00045 public:
00046 INLINE ProtoDatabase();
00047 INLINE ProtoDatabase(const ProtoDatabase<S, T> &m);
00048
00049 virtual INLINE ~ProtoDatabase();
00050
00051 INLINE const T *find_ref(const S &key) const;
00052 INLINE T *find_ref(const S &key);
00053
00054
00055 INLINE Boolean member(const S &key) const;
00056
00057
00058 INLINE const T &operator[] (const S &key) const;
00059 INLINE T &operator[] (const S &key);
00060
00061 };
00062
00063
00064
00065
00066
00067 template <class S, class T>
00068 INLINE Boolean
00069 ProtoDatabase<S, T>::_less(const BMKey &key1, const BMKey &key2) const
00070 {
00071 const S * key1_ptr = (S *) key1._keyptr;
00072 const S * key2_ptr = (S *) key2._keyptr;
00073
00074 return (*key1_ptr) < (*key2_ptr);
00075 }
00076
00077 template <class S, class T>
00078 INLINE Boolean
00079 ProtoDatabase<S, T>::_equal(const BMKey &key1, const BMKey &key2) const
00080 {
00081 const S * key1_ptr = (S *) key1._keyptr;
00082 const S * key2_ptr = (S *) key2._keyptr;
00083
00084 return (*key1_ptr) == (*key2_ptr);
00085 }
00086
00087 template <class S, class T>
00088 INLINE void
00089 ProtoDatabase<S, T>::_print(ostream & o, const BMKey &key) const
00090 {
00091 const S *key_ptr = (S *) key._keyptr;
00092
00093 o << (*key_ptr);
00094 }
00095
00096 template <class S, class T>
00097 INLINE
00098 ProtoDatabase<S, T>::ProtoDatabase()
00099 {
00100
00101 }
00102
00103 template <class S, class T>
00104 INLINE
00105 ProtoDatabase<S, T>::ProtoDatabase(const ProtoDatabase<S, T> &m)
00106 {
00107
00108 (*this) = m;
00109 }
00110
00111 template <class S, class T>
00112 INLINE
00113 ProtoDatabase<S, T>::~ProtoDatabase()
00114 {
00115
00116 }
00117
00118 template <class S, class T>
00119 INLINE const T *
00120 ProtoDatabase<S, T>::find_ref(const S &key) const
00121 {
00122 BMKey findkey;
00123
00124 findkey._keyptr = (void *) &key;
00125
00126 return (const T *) TypedBaseMap<S,T>::find_ref(findkey);
00127 }
00128
00129 template <class S, class T>
00130 INLINE T *
00131 ProtoDatabase<S, T>::find_ref(const S &key)
00132 {
00133 BMKey findkey;
00134
00135 findkey._keyptr = (void *) &key;
00136
00137 return (T *) TypedBaseMap<S,T>::find_ref(findkey);
00138 }
00139
00140 template <class S, class T>
00141 INLINE Boolean
00142 ProtoDatabase<S, T>::member(const S &key) const
00143 {
00144 BMKey memkey;
00145
00146 memkey._keyptr = (void *) &key;
00147
00148 return TypedBaseMap<S,T>::member(memkey);
00149 }
00150
00151 template <class S, class T>
00152 INLINE const T &
00153 ProtoDatabase<S, T>::operator[] (const S &key) const
00154 {
00155 return *find_ref(key);
00156 }
00157
00158 template <class S, class T>
00159 INLINE T &
00160 ProtoDatabase<S, T>::operator[] (const S &key)
00161 {
00162 return *find_ref(key);
00163 }
00164
00165 #endif
|