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 <map>
29 #include <list>
30 #include <utility>
31 #include <string>
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,
43  ParameterList &params);
45 
46  virtual void registerParameters();
47  virtual void execute();
48 
49  const char * name();
50 
51  std::string skill_string();
52 
53  private:
54  bool __execute;
55 
56  /// @cond INTERNALS
57  class ParameterValueBase
58  {
59  public:
60  virtual ~ParameterValueBase() {}
61  };
62 
63  template <typename T>
64  class ParameterValue : public ParameterValueBase
65  {
66  public:
67  ParameterValue()
68  {
69  __value = 0;
70  }
71 
72  T get_value() const
73  {
74  return __value;
75  }
76 
77  T * get_value_ptr()
78  {
79  return &__value;
80  }
81 
82  void set_value(T value)
83  {
84  __value = value;
85  }
86  private:
87  T __value;
88  };
89  /// @endcond
90 
91  std::map<std::string, ParameterValueBase *> __param_values;
92  ParameterList __params;
93 };
94 
95 
96 #endif
std::string skill_string()
Get skill string for this string.
virtual void registerParameters()
Register parameters.
virtual void execute()
Execute skill.
XabslSkillWrapper(const char *name, xabsl::ErrorHandler &error_handler, ParameterList &params)
Constructor.
~XabslSkillWrapper()
Destructor.
const char * name()
Get name of the skill.
std::list< std::pair< std::string, std::string > > ParameterList
Parameter list.
Definition: skill_wrapper.h:40
Xabsl Skill Wrapper.
Definition: skill_wrapper.h:33