Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * skill_wrapper.h - Wrap a skill as XABSL basic behavior 00004 * 00005 * Created: Sun Aug 10 10:22:22 2008 00006 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_XABSL_SKILL_WRAPPER_H_ 00024 #define __PLUGINS_XABSL_SKILL_WRAPPER_H_ 00025 00026 #include <XabslEngine/XabslBasicBehavior.h> 00027 00028 #include <map> 00029 #include <list> 00030 #include <utility> 00031 #include <string> 00032 00033 class XabslSkillWrapper : public xabsl::BasicBehavior 00034 { 00035 public: 00036 /** Parameter list. 00037 * Defines the parameters of a skill. It's a list of name/type pairs. The name 00038 * is the name of the parameter, the type is the value type. 00039 */ 00040 typedef std::list<std::pair<std::string, std::string> > ParameterList; 00041 00042 XabslSkillWrapper(const char *name, xabsl::ErrorHandler &error_handler, 00043 ParameterList ¶ms); 00044 ~XabslSkillWrapper(); 00045 00046 virtual void registerParameters(); 00047 virtual void execute(); 00048 00049 const char * name(); 00050 00051 std::string skill_string(); 00052 00053 private: 00054 bool __execute; 00055 00056 class ParameterValueBase 00057 { 00058 public: 00059 virtual ~ParameterValueBase() {} 00060 }; 00061 00062 template <typename T> 00063 class ParameterValue : public ParameterValueBase 00064 { 00065 public: 00066 ParameterValue() 00067 { 00068 __value = 0; 00069 } 00070 00071 T get_value() const 00072 { 00073 return __value; 00074 } 00075 00076 T * get_value_ptr() 00077 { 00078 return &__value; 00079 } 00080 00081 void set_value(T value) 00082 { 00083 __value = value; 00084 } 00085 private: 00086 T __value; 00087 }; 00088 00089 std::map<std::string, ParameterValueBase *> __param_values; 00090 ParameterList __params; 00091 }; 00092 00093 00094 #endif