00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00031 #ifndef __VDBL_LEXIINDEX_H
00032 #define __VDBL_LEXIINDEX_H
00033
00034 #include <map>
00035 #include <list>
00036 #include <triple>
00037 #include <vdbl_listindex.h>
00038
00039 __VDBL_BEGIN_NAMESPACE
00040
00041 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00042 #pragma set woff 1209
00043 #endif
00044
00045 template <class _TR, class _TS>
00046 class _VDBL_index_lex2 : public _VDBL_index_l<std::pair<_TR, _TS> >
00047 {
00048 private:
00049 typedef typename std::pair<_TR,_TS> type_t;
00050 typedef std::list<std::pair<type_t, _VDBL_rowid> > idx_t;
00051 typedef std::map<_VDBL_rowid, typename idx_t::iterator> itt_t;
00052 typedef _VDBL_index_l<std::pair<_TR, _TS> > _Base;
00053
00054 _VDBL_colid c2;
00055
00056 public:
00057 _VDBL_index_lex2(_VDBL_colid __c, _VDBL_colid __c2) : _Base(__c), c2(__c2) {}
00058 virtual ~_VDBL_index_lex2() {}
00059
00060 virtual VDBL_index_type type() const { return vdbl_lexi_index; }
00061
00062 virtual bool ins(const _VDBL_row& _r, const _VDBL_rowid rid)
00063 {
00064 bool error;
00065 const _VDBL_col& _c(_r.get_col(this->c, error));
00066 if(error)
00067 return false;
00068 else
00069 {
00070 const _VDBL_col& _c2(_r.get_col(c2, error));
00071 if(error)
00072 return false;
00073 else
00074 {
00075 const _TR* T;
00076 const _TS* S;
00077 _c.get_ptr(T);
00078 _c2.get_ptr(S);
00079 type_t R(std::make_pair(*T, *S));
00080 return ins(&R, rid);
00081 }
00082 }
00083 }
00084 };
00085
00086 template <class _TR, class _TS>
00087 class lexi_pair_index : public _VDBL_index_lex2<_TR, _TS>
00088 {
00089 private:
00090 typedef _VDBL_index_lex2<_TR, _TS> _Base;
00091 };
00092
00093 template <class _TR, class _TS>
00094 class lexi_pair_index_def : public _VDBL_index_lex2<_TR, _TS>
00095 {
00096 private:
00097 typedef _VDBL_index_lex2<_TR, _TS> _Base;
00098 typedef typename std::pair<_TR, _TS> type_t;
00099
00100 _TR default_value1;
00101 _TS default_value2;
00102
00103 public:
00104 lexi_pair_index_def(_VDBL_colid __c, _VDBL_colid __c2, const _TR& __d,
00105 const _TS& __d2)
00106 : _Base(__c, __c2), default_value1(__d), default_value2(__d2)
00107 {}
00108 virtual ~lexi_pair_index_def() {}
00109
00110 public:
00111 virtual bool ins(const _VDBL_row& _r, const _VDBL_rowid rid)
00112 {
00113 bool error1;
00114 bool error2;
00115 const _VDBL_col& _c(_r.get_col(this->c, error1));
00116 const _VDBL_col& _c2(_r.get_col(this->c2, error2));
00117 type_t U(std::make_pair(default_value1,default_value2));
00118
00119 if(!error1)
00120 {
00121 const _TR *T;
00122 _c.get_ptr(T);
00123 U.first = *T;
00124 }
00125 if(!error2)
00126 {
00127 const _TS *T;
00128 _c2.get_ptr(T);
00129 U.second = *T;
00130 }
00131 return ins(&U, rid);
00132 }
00133 };
00134
00135 template <class _TR, class _TS, class _TT>
00136 class _VDBL_index_lex3 : public _VDBL_index_l<std::triple<_TR, _TS, _TT> >
00137 {
00138 private:
00139 typedef typename std::triple<_TR,_TS,_TT> type_t;
00140 typedef std::list<std::pair<type_t, _VDBL_rowid> > idx_t;
00141 typedef std::map<_VDBL_rowid, typename idx_t::iterator> itt_t;
00142 typedef _VDBL_index_l<std::pair<_TR, _TS> > _Base;
00143
00144 _VDBL_colid c2;
00145 _VDBL_colid c3;
00146
00147 public:
00148 _VDBL_index_lex3(_VDBL_colid __c, _VDBL_colid __c2, _VDBL_colid __c3)
00149 : _Base(__c), c2(__c2), c3(__c3) {}
00150 virtual ~_VDBL_index_lex3() {}
00151
00152 virtual VDBL_index_type type() const { return vdbl_lexi_index; }
00153
00154 virtual bool ins(const _VDBL_row& _r, const _VDBL_rowid rid)
00155 {
00156 bool error;
00157 const _VDBL_col& _c(_r.get_col(this->c, error));
00158 if(error)
00159 return false;
00160 else
00161 {
00162 const _VDBL_col& _c2(_r.get_col(c2, error));
00163 if(error)
00164 return false;
00165 else
00166 {
00167 const _VDBL_col& _c3(_r.get_col(c3, error));
00168 if(error)
00169 return false;
00170 else
00171 {
00172 const _TR* T;
00173 const _TS* S;
00174 const _TT* R;
00175 _c.get_ptr(T);
00176 _c2.get_ptr(S);
00177 _c3.get_ptr(R);
00178 type_t U(std::make_triple(*T, *S, *R));
00179 return ins(&U, rid);
00180 }
00181 }
00182 }
00183 }
00184 };
00185
00186 template <class _TR, class _TS, class _TT>
00187 class lexi_triple_index : public _VDBL_index_lex3<_TR, _TS, _TT>
00188 {
00189 private:
00190 typedef _VDBL_index_lex3<_TR, _TS, _TT> _Base;
00191 };
00192
00193 template <class _TR, class _TS, class _TT>
00194 class lexi_triple_index_def : public _VDBL_index_lex3<_TR, _TS, _TT>
00195 {
00196 private:
00197 typedef _VDBL_index_lex3<_TR, _TS, _TT> _Base;
00198 typedef typename std::pair<_TR, _TS> type_t;
00199
00200 _TR default_value1;
00201 _TS default_value2;
00202 _TT default_value3;
00203
00204 public:
00205 lexi_triple_index_def(_VDBL_colid __c, _VDBL_colid __c2, const _TR& __d,
00206 const _TS& __d2, const _TT& __d3)
00207 : _Base(__c, __c2), default_value1(__d), default_value2(__d2),
00208 default_value3(__d3)
00209 {}
00210 virtual ~lexi_triple_index_def() {}
00211
00212 public:
00213 virtual bool ins(const _VDBL_row& _r, const _VDBL_rowid rid)
00214 {
00215 bool error1;
00216 bool error2;
00217 bool error3;
00218 const _VDBL_col& _c(_r.get_col(this->c, error1));
00219 const _VDBL_col& _c2(_r.get_col(this->c2, error2));
00220 const _VDBL_col& _c3(_r.get_col(this->c3, error3));
00221 type_t U(std::make_triple(default_value1,default_value2,default_value3));
00222
00223 if(!error1)
00224 {
00225 const _TR *T;
00226 _c.get_ptr(T);
00227 U.first = *T;
00228 }
00229 if(!error2)
00230 {
00231 const _TS *T;
00232 _c2.get_ptr(T);
00233 U.second = *T;
00234 }
00235 if(!error3)
00236 {
00237 const _TT *T;
00238 _c3.get_ptr(T);
00239 U.third = *T;
00240 }
00241 return ins(&U, rid);
00242 }
00243 };
00244
00245 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00246 #pragma reset woff 1209
00247 #endif
00248
00249 __VDBL_END_NAMESPACE
00250
00251 #endif
00252
00253
00254
00255