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 _INFERENCE_ENGINE_H
00028 #define _INFERENCE_ENGINE_H
00029
00030 #include <iostream>
00031 #include <coconut_config.h>
00032 #include <search_node.h>
00033 #include <termreason.h>
00034 #include <gptr.h>
00035 #include <string>
00036 #include <dbtools.h>
00037 #include <viewdbase>
00038 #include <ie_statistic.h>
00039 #include <control_data.h>
00040 #include <ie_rettype.h>
00041
00042 using namespace vgtl;
00043
00044 class inference_engine
00045 {
00046 protected:
00047 std::string __name;
00048 const gptr<work_node>* __wnode;
00049 work_node_context* __wnc;
00050 vdbl::viewdbase __vdb;
00051 std::vector<delta_id> _old_deltas, _new_deltas;
00052
00053 private:
00054 void __prep_delta_list();
00055
00056 public:
00057
00058 inference_engine(const gptr<work_node>& wnode, const std::string& __n)
00059 : __name(__n), __wnode(&wnode),
00060 __wnc(new work_node_context(&wnode)),
00061 __vdb(*(*wnode).database()->get_local_copy(),
00062 (*wnode).get_dbuserid(), *__wnc,
00063 std::vector<std::pair<vdbl::tableid,vdbl::rowid> >(
00064 (*wnode).get_annotations().begin(),
00065 (*wnode).get_annotations().end())),
00066 _old_deltas(), _new_deltas()
00067 { __prep_delta_list(); }
00068
00069 virtual ~inference_engine() { delete __wnc; }
00070
00071 virtual bool update_engine(const gptr<work_node>& wnode)
00072 {
00073 __wnode = &wnode;
00074 swap(_old_deltas, _new_deltas);
00075 __prep_delta_list();
00076 return true;
00077 }
00078
00079
00080 std::pair<std::list<delta_id>,std::list<delta_id> > new_deltas();
00081
00082 const delta* get_delta(const delta_id& __d) const
00083 { return &(*__wnode)->get_delta(__d); }
00084
00085 const model* get_model() const
00086 { return (*__wnode)->get_model(); }
00087
00088 virtual ie_return_type infer(const control_data& __c)
00089 { return ie_return_type(termination_reason(0, std::string("SUCCESS"))); }
00090
00091 const std::string& get_name() const { return __name; }
00092
00093
00094 virtual statistic_info last_call_stat() { return statistic_info(); }
00095 virtual statistic_info cumulative_stat() { return statistic_info(); }
00096 };
00097
00098 #endif