Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "engine.hpp"
00022 #include "contexts.hpp"
00023
00024 #include "../../foreach.hpp"
00025 #include "../../log.hpp"
00026
00027 namespace ai {
00028
00029 static lg::log_domain log_ai_engine("ai/engine");
00030 #define DBG_AI_ENGINE LOG_STREAM(debug, log_ai_engine)
00031 #define LOG_AI_ENGINE LOG_STREAM(info, log_ai_engine)
00032 #define ERR_AI_ENGINE LOG_STREAM(err, log_ai_engine)
00033
00034 engine::engine( readonly_context &context, const config &cfg )
00035 : ai_(context)
00036 , ai_context_(NULL)
00037 , engine_(cfg["engine"])
00038 , id_(cfg["id"])
00039 , name_(cfg["name"])
00040 {
00041 LOG_AI_ENGINE << "side "<< ai_.get_side() << " : "<<" created engine with name=["<<name_<<"]"<<std::endl;
00042 }
00043
00044 engine::~engine()
00045 {
00046 }
00047
00048
00049 void engine::parse_aspect_from_config( readonly_context &context, const config &cfg, const std::string &id, std::back_insert_iterator< std::vector< aspect_ptr > > b )
00050 {
00051 engine_ptr eng = context.get_engine_by_cfg(cfg);
00052 if (eng){
00053
00054 eng->do_parse_aspect_from_config(cfg, id, b);
00055 }
00056 }
00057
00058 void engine::parse_candidate_action_from_config( rca_context &context, const config &cfg, std::back_insert_iterator<std::vector< candidate_action_ptr > > b )
00059 {
00060 engine_ptr eng = context.get_engine_by_cfg(cfg);
00061 if (eng){
00062
00063 eng->do_parse_candidate_action_from_config(context, cfg, b);
00064 }
00065 }
00066
00067 void engine::parse_engine_from_config( readonly_context &context, const config &cfg, std::back_insert_iterator<std::vector< engine_ptr > > b )
00068 {
00069 engine_ptr eng = context.get_engine_by_cfg(cfg);
00070 if (eng){
00071
00072 eng->do_parse_engine_from_config(cfg, b);
00073 }
00074 }
00075
00076
00077 void engine::parse_goal_from_config( readonly_context &context, const config &cfg, std::back_insert_iterator<std::vector< goal_ptr > > b )
00078 {
00079 engine_ptr eng = context.get_engine_by_cfg(cfg);
00080 if (eng){
00081
00082 eng->do_parse_goal_from_config(cfg, b);
00083 }
00084 }
00085
00086
00087 void engine::parse_stage_from_config( ai_context &context, const config &cfg, std::back_insert_iterator<std::vector< stage_ptr > > b )
00088 {
00089 engine_ptr eng = context.get_engine_by_cfg(cfg);
00090 if (eng){
00091
00092 eng->do_parse_stage_from_config(context, cfg, b);
00093 }
00094 }
00095
00096 void engine::do_parse_aspect_from_config( const config &, const std::string &, std::back_insert_iterator< std::vector<aspect_ptr> > )
00097 {
00098
00099 }
00100
00101
00102 void engine::do_parse_candidate_action_from_config( rca_context &, const config &, std::back_insert_iterator<std::vector< candidate_action_ptr > > ){
00103
00104 }
00105
00106 void engine::do_parse_engine_from_config( const config &, std::back_insert_iterator<std::vector< engine_ptr > > ){
00107
00108 }
00109
00110
00111 void engine::do_parse_goal_from_config( const config &, std::back_insert_iterator<std::vector< goal_ptr > > ){
00112
00113 }
00114
00115
00116 void engine::do_parse_stage_from_config( ai_context &, const config &, std::back_insert_iterator<std::vector< stage_ptr > > )
00117 {
00118
00119 }
00120
00121 std::string engine::evaluate(const std::string& )
00122 {
00123 return "evaluate command is not implemented by this engine";
00124 }
00125
00126 void engine::set_ai_context(ai_context_ptr ai_context)
00127 {
00128 ai_context_ = ai_context;
00129 }
00130
00131 ai_context_ptr engine::get_ai_context()
00132 {
00133 return ai_context_;
00134 }
00135
00136 config engine::to_config() const
00137 {
00138 config cfg;
00139 cfg["engine"] = engine_;
00140 cfg["name"] = get_name();
00141 return cfg;
00142 }
00143
00144 readonly_context& engine::get_readonly_context()
00145 {
00146 return ai_;
00147 }
00148
00149
00150 }