00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00027 #ifndef _DBTOOLS_H_
00028 #define _DBTOOLS_H_
00029
00030 #include <list>
00031 #include <database>
00032 #include <db_method>
00033
00034 class work_node_context : public vdbl::context
00035 {
00036 const gptr<work_node>* __wn;
00037
00038 public:
00039 work_node_context() : __wn(NULL) {}
00040 work_node_context(const gptr<work_node>* _i) : __wn(_i) {}
00041 work_node_context(const work_node_context& _w) : __wn(_w.__wn) {}
00042 virtual ~work_node_context() {}
00043
00044 work_node_context& operator=(const work_node_context& _w)
00045 { __wn = _w.__wn; return *this; }
00046
00047 const gptr<work_node>* wn() const { return __wn; }
00048 };
00049
00050 class point_check_feasibility : public vdbl::method<bool>
00051 {
00052 public:
00053 typedef work_node_context context;
00054
00055 private:
00056 typedef vdbl::method<bool> _Base;
00057 vdbl::colid x_ci, L_ci, f_ci;
00058 const vdbl::row* _r;
00059 const work_node_context* wnc;
00060
00061 public:
00062 typedef bool return_type;
00063
00064 point_check_feasibility(vdbl::colid _x, vdbl::colid _L, vdbl::colid _f)
00065 : _Base(), x_ci(_x), L_ci(_L), f_ci(_f), _r(), wnc(NULL) {}
00066 point_check_feasibility(const point_check_feasibility& _i)
00067 : _Base(_i), x_ci(_i.x_ci), L_ci(_i.L_ci), f_ci(_i.f_ci), _r(_i._r),
00068 wnc(_i.wnc) {}
00069 virtual ~point_check_feasibility() {}
00070
00071 bool operator() () const;
00072 bool def() const { return operator()(); }
00073 void setcontext(const context* c, const vdbl::row* r)
00074 { _r = r; wnc = (work_node_context *) c; }
00075 };
00076
00077 class box_check_intersection : public vdbl::method<bool>
00078 {
00079 public:
00080 typedef work_node_context context;
00081
00082 private:
00083 typedef vdbl::method<bool> _Base;
00084 vdbl::colid x_ci;
00085 const vdbl::row* _r;
00086 const work_node_context* wnc;
00087
00088 public:
00089 typedef bool return_type;
00090
00091 box_check_intersection(vdbl::colid _x)
00092 : _Base(), x_ci(_x), _r(), wnc(NULL) {}
00093 box_check_intersection(const box_check_intersection& _i)
00094 : _Base(_i), x_ci(_i.x_ci), _r(_i._r), wnc(_i.wnc) {}
00095 virtual ~box_check_intersection() {}
00096
00097 bool operator() () const;
00098 bool def() const { return operator()(); }
00099 void setcontext(const context* c, const vdbl::row* r)
00100 { _r = r; wnc = (work_node_context *) c; }
00101 };
00102
00103 typedef std::list<vdbl::col_spec> dbt_row;
00104
00105 template < class _C >
00106 inline void add_to_dbt_row(dbt_row& dbr, const std::string& nm, const _C& cont)
00107 {
00108 dbr.push_back(vdbl::col_spec(nm, vdbl::col(vdbl::typed_col<_C>(cont))));
00109 }
00110
00111 template < class _C >
00112 inline void add_to_dbt_row(dbt_row& dbr, const char* nm, const _C& cont)
00113 {
00114 add_to_dbt_row(dbr, std::string(nm), cont);
00115 }
00116
00117 #endif // _DBTOOLS_H