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_INDEX_H
00032 #define __VDBL_INDEX_H
00033
00034 #include <list>
00035 #include <typeinfo>
00036 #include <counted_ptr.h>
00037 #include <vdbl_config.h>
00038 #include <vdbl_types.h>
00039 #include <vdbl_col.h>
00040
00041 __VDBL_BEGIN_NAMESPACE
00042
00043 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00044 #pragma set woff 1209
00045 #endif
00046
00047 typedef enum { vdbl_list_index, vdbl_map_index, vdbl_lexi_index, vdbl_index_error } VDBL_index_type;
00048
00049 class __VDBL_index
00050 {
00051 public:
00052 __VDBL_index() {}
00053 virtual ~__VDBL_index() {}
00054
00055 virtual VDBL_index_type type() const VDBL_PURE_VIRTUAL
00056
00057 virtual void destroy() VDBL_PURE_VIRTUAL
00058 virtual bool clear() VDBL_PURE_VIRTUAL
00059 virtual bool ins(const _VDBL_row& _r, const _VDBL_rowid rid)
00060 VDBL_PURE_VIRTUAL
00061 virtual bool del(const _VDBL_rowid rid) VDBL_PURE_VIRTUAL
00062
00063 virtual bool maximal(_VDBL_rowid& r) const VDBL_PURE_VIRTUAL
00064 virtual bool minimal(_VDBL_rowid& r) const VDBL_PURE_VIRTUAL
00065
00066 virtual bool maximal(std::list<_VDBL_rowid>& _Ct) const VDBL_PURE_VIRTUAL
00067 virtual bool minimal(std::list<_VDBL_rowid>& _Ct) const VDBL_PURE_VIRTUAL
00068
00069 virtual bool getval(const void* c, const std::type_info&, _VDBL_rowid& r) const
00070 VDBL_PURE_VIRTUAL
00071 virtual bool getval(const void* c, const std::type_info&, std::list<_VDBL_rowid>& _Ct) const
00072 VDBL_PURE_VIRTUAL
00073 };
00074
00075 class index
00076 {
00077 private:
00078 counted_ptr<__VDBL_index> _i;
00079
00080 public:
00081 index(__VDBL_index* __i = NULL) : _i(__i) {}
00082 ~index() { if(_i.get()) { _i->destroy(); } }
00083
00084 VDBL_index_type type() const { return _i.get() ? _i->type() : vdbl_index_error; }
00085
00086 bool clear() { return _i.get() && _i->clear(); }
00087 bool ins(const _VDBL_row& _r, const _VDBL_rowid rid)
00088 { return _i.get() && _i->ins(_r, rid); }
00089 bool del(const _VDBL_rowid rid)
00090 { return _i.get() && _i->del(rid); }
00091
00092 bool maximal(_VDBL_rowid& r) const { return _i.get() ? _i->maximal(r) : false; }
00093 bool minimal(_VDBL_rowid& r) const { return _i.get() ? _i->minimal(r) : false ; }
00094
00095 template <class _Al>
00096 bool maximal(std::list<_VDBL_rowid, _Al>& _Ct) const
00097 { if(_i.get()) return _i->maximal(_Ct); else return false;}
00098 template <class _Al>
00099 bool minimal(std::list<_VDBL_rowid, _Al>& _Ct) const
00100 { if(_i.get()) return _i->minimal(_Ct); else return false;}
00101 template < template <class _TT, class _TA> class _SqCtr, class _Al >
00102 bool maximal(_SqCtr<_VDBL_rowid, _Al>& _Ct) const
00103 { if(_i.get()) {
00104 std::list<_VDBL_rowid> _l;
00105 bool ret = _i->maximal(_l);
00106 for(std::list<_VDBL_rowid>::const_iterator x = _l.begin(); x != _l.end();
00107 ++x)
00108 _Ct.insert(_Ct.end(), *x);
00109 return ret;
00110 } else return false;}
00111 template < template <class _TT, class _TA> class _SqCtr, class _Al >
00112 bool minimal(_SqCtr<_VDBL_rowid, _Al>& _Ct) const
00113 { if(_i.get()) {
00114 std::list<_VDBL_rowid> _l;
00115 bool ret = _i->minimal(_l);
00116 for(std::list<_VDBL_rowid>::const_iterator x = _l.begin(); x != _l.end();
00117 ++x)
00118 _Ct.insert(_Ct.end(), *x);
00119 return ret;
00120 } else return false;}
00121
00122 template < class _T >
00123 bool getval(const _T& c, _VDBL_rowid& r) const
00124 { if(_i.get()) return _i->getval((void*)&c, typeid(_T), r); else return -1; }
00125 template < class _T, template <class _TT, class _TA> class _SqCtr, class _Al >
00126 bool getval(const _T& c, std::list<_VDBL_rowid>& _Ct) const
00127 { if(_i.get()) return _i->getval((void*)&c, typeid(_T), _Ct); else return false; }
00128 template < class _T, template <class _TT, class _TA> class _SqCtr, class _Al >
00129 bool getval(const _T& c, _SqCtr<_VDBL_rowid, _Al>& _Ct) const
00130 { if(_i.get()) {
00131 std::list<_VDBL_rowid> _l;
00132 bool ret = _i->getval((void*)&c, typeid(_T), _l);
00133 for(std::list<_VDBL_rowid>::const_iterator x = _l.begin(); x != _l.end();
00134 ++x)
00135 _Ct.insert(_Ct.end(), *x);
00136 return ret;
00137 } else return false;}
00138 };
00139
00140 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00141 #pragma reset woff 1209
00142 #endif
00143
00144 __VDBL_END_NAMESPACE
00145
00146 #endif
00147
00148
00149
00150