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
00028 #ifndef _INFERENCE_ENGINE_H
00029 #define _INFERENCE_ENGINE_H
00030
00031 #include <iostream>
00032 #include <coconut_config.h>
00033 #include <search_node.h>
00034 #include <termreason.h>
00035 #include <gptr.h>
00036 #include <string>
00037 #include <dbtools.h>
00038 #include <viewdbase>
00039 #include <ie_statistic.h>
00040 #include <control_data.h>
00041 #include <ie_rettype.h>
00042 #include <api_exception.h>
00043
00044 using namespace vgtl;
00045
00046 namespace coco {
00047
00049
00055 class inference_engine_exception : public api_exception
00056 {
00057 public:
00059 inference_engine_exception(const std::string& msg) :
00060 api_exception(apiee_inference_engine, msg) {}
00062 inference_engine_exception(const char* msg) :
00063 api_exception(apiee_inference_engine, msg) {}
00064
00066 virtual ~inference_engine_exception() throw() {}
00067 };
00068
00070
00076 class inference_engine
00077 {
00078 protected:
00080 std::string __name;
00082 const gptr<work_node>* __wnode;
00085 const work_node_context* __wnc;
00087 const vdbl::viewdbase& __vdb;
00090 std::vector<delta_id> _old_deltas;
00093 std::vector<delta_id> _new_deltas;
00094
00095 private:
00097 void __prep_delta_list();
00098
00099 public:
00102 inference_engine(const gptr<work_node>& wnode, const std::string& __n)
00103 : __name(__n), __wnode(&wnode),
00104 __wnc((*wnode).get_work_node_context()),
00105 __vdb((*wnode).get_viewdbase()),
00106 _old_deltas(), _new_deltas()
00107 { __prep_delta_list(); }
00108
00110 virtual ~inference_engine() {}
00111
00113 virtual bool update_engine(const gptr<work_node>& wnode)
00114 {
00115 __wnode = &wnode;
00116 swap(_old_deltas, _new_deltas);
00117 __prep_delta_list();
00118 return true;
00119 }
00120
00123 std::pair<std::list<delta_id>,std::list<delta_id> > new_deltas();
00124
00126 const delta* get_delta(const delta_id& __d) const
00127 { return &(*__wnode)->get_delta(__d); }
00128
00130 const model* get_model() const
00131 { return (*__wnode)->get_model(); }
00132
00138 virtual ie_return_type infer(const control_data& __c)
00139 { return ie_return_type(termination_reason(0, std::string("SUCCESS"))); }
00140
00142 const std::string& get_name() const { return __name; }
00143
00146 virtual statistic_info last_call_stat() { return statistic_info(); }
00149 virtual statistic_info cumulative_stat() { return statistic_info(); }
00150 };
00151
00152 }
00153
00154 #endif