Fawkes API  Fawkes Development Version
skill_wrapper.h
1 
2 /***************************************************************************
3  * skill_wrapper.h - Wrap a skill as XABSL basic behavior
4  *
5  * Created: Sun Aug 10 10:22:22 2008
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_XABSL_SKILL_WRAPPER_H_
24 #define _PLUGINS_XABSL_SKILL_WRAPPER_H_
25 
26 #include <XabslEngine/XabslBasicBehavior.h>
27 
28 #include <list>
29 #include <map>
30 #include <string>
31 #include <utility>
32 
33 class XabslSkillWrapper : public xabsl::BasicBehavior
34 {
35 public:
36  /** Parameter list.
37  * Defines the parameters of a skill. It's a list of name/type pairs. The name
38  * is the name of the parameter, the type is the value type.
39  */
40  typedef std::list<std::pair<std::string, std::string>> ParameterList;
41 
42  XabslSkillWrapper(const char *name, xabsl::ErrorHandler &error_handler, ParameterList &params);
44 
45  virtual void registerParameters();
46  virtual void execute();
47 
48  const char *name();
49 
50  std::string skill_string();
51 
52 private:
53  bool execute_;
54 
55  /// @cond INTERNALS
56  class ParameterValueBase
57  {
58  public:
59  virtual ~ParameterValueBase()
60  {
61  }
62  };
63 
64  template <typename T>
65  class ParameterValue : public ParameterValueBase
66  {
67  public:
68  ParameterValue()
69  {
70  value_ = 0;
71  }
72 
73  T
74  get_value() const
75  {
76  return value_;
77  }
78 
79  T *
80  get_value_ptr()
81  {
82  return &value_;
83  }
84 
85  void
86  set_value(T value)
87  {
88  value_ = value;
89  }
90 
91  private:
92  T value_;
93  };
94  /// @endcond
95 
96  std::map<std::string, ParameterValueBase *> param_values_;
97  ParameterList params_;
98 };
99 
100 #endif
XabslSkillWrapper::registerParameters
virtual void registerParameters()
Register parameters.
Definition: skill_wrapper.cpp:71
XabslSkillWrapper::XabslSkillWrapper
XabslSkillWrapper(const char *name, xabsl::ErrorHandler &error_handler, ParameterList &params)
Constructor.
Definition: skill_wrapper.cpp:41
XabslSkillWrapper::name
const char * name()
Get name of the skill.
Definition: skill_wrapper.cpp:64
XabslSkillWrapper::ParameterList
std::list< std::pair< std::string, std::string > > ParameterList
Parameter list.
Definition: skill_wrapper.h:40
XabslSkillWrapper::~XabslSkillWrapper
~XabslSkillWrapper()
Destructor.
Definition: skill_wrapper.cpp:51
XabslSkillWrapper
Xabsl Skill Wrapper.
Definition: skill_wrapper.h:34
XabslSkillWrapper::skill_string
std::string skill_string()
Get skill string for this string.
Definition: skill_wrapper.cpp:105
XabslSkillWrapper::execute
virtual void execute()
Execute skill.
Definition: skill_wrapper.cpp:94