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

inference_engine.h

Go to the documentation of this file.
00001 // Inference Engine Basics 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 _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   // the constructor for a basic inference engine
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   // returns the deltas to be applied and unapplied
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   // collect statistics
00094   virtual statistic_info last_call_stat() { return statistic_info(); }
00095   virtual statistic_info cumulative_stat() { return statistic_info(); }
00096 };
00097 
00098 #endif /* _INFERENCE_ENGINE_H */

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