Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

dbtools.h

Go to the documentation of this file.
00001 // Database Tools implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2003 Hermann Schichl
00004 //
00005 // This file is part of the COCONUT API.  This library
00006 // is free software; you can redistribute it and/or modify it under the
00007 // terms of the Library GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // Library GNU General Public License for more details.
00015 
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the Library GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the Library GNU General Public License.
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

Generated on Tue Nov 4 01:57:57 2003 for COCONUT API by doxygen1.2.18