Fawkes API  Fawkes Development Version
SkillerInterface.h
1 
2 /***************************************************************************
3  * SkillerInterface.h - Fawkes BlackBoard Interface - SkillerInterface
4  *
5  * Templated created: Thu Oct 12 10:49:19 2006
6  * Copyright 2008 Tim Niemueller
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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _INTERFACES_SKILLERINTERFACE_H_
25 #define _INTERFACES_SKILLERINTERFACE_H_
26 
27 #include <interface/interface.h>
28 #include <interface/message.h>
29 #include <interface/field_iterator.h>
30 
31 namespace fawkes {
32 
34 {
35  /// @cond INTERNALS
36  INTERFACE_MGMT_FRIENDS(SkillerInterface)
37  /// @endcond
38  public:
39  /* constants */
40 
41  /**
42  This determines the current status of skill execution.
43  */
44  typedef enum {
45  S_INACTIVE /**< No skill is running. */,
46  S_FINAL /**< The skill string has been successfully processed. */,
47  S_RUNNING /**< The execution is still running. */,
48  S_FAILED /**< The execution failed and cannot succeed anymore. */
50  const char * tostring_SkillStatusEnum(SkillStatusEnum value) const;
51 
52  private:
53  /** Internal data storage, do NOT modify! */
54  typedef struct {
55  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
56  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
57  char skill_string[1024]; /**<
58  Currently executed skill string, at least the first 1023 bytes of it.
59  Must be properly null-terminated.
60  */
61  char error[128]; /**<
62  String describing the error. Can be set by a skill when it fails.
63  */
64  uint32_t exclusive_controller; /**<
65  Instance serial of the exclusive controller of the skiller. If this does not
66  carry your instance serial your exec messages will be ignored. Aquire control with
67  the AquireControlMessage. Make sure you release control before exiting.
68  */
69  uint32_t msgid; /**<
70  The ID of the message that is currently being processed,
71  or 0 if no message is being processed.
72  */
73  int32_t status; /**<
74  The status of the current skill execution.
75  */
76  } SkillerInterface_data_t;
77 
78  SkillerInterface_data_t *data;
79 
80  interface_enum_map_t enum_map_SkillStatusEnum;
81  public:
82  /* messages */
83  class ExecSkillMessage : public Message
84  {
85  private:
86  /** Internal data storage, do NOT modify! */
87  typedef struct {
88  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
89  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
90  char skill_string[1024]; /**<
91  Currently executed skill string, at least the first 1023 bytes of it.
92  Must be properly null-terminated.
93  */
94  } ExecSkillMessage_data_t;
95 
96  ExecSkillMessage_data_t *data;
97 
98  interface_enum_map_t enum_map_SkillStatusEnum;
99  public:
100  ExecSkillMessage(const char * ini_skill_string);
103 
104  explicit ExecSkillMessage(const ExecSkillMessage *m);
105  /* Methods */
106  char * skill_string() const;
107  void set_skill_string(const char * new_skill_string);
108  size_t maxlenof_skill_string() const;
109  virtual Message * clone() const;
110  };
111 
113  {
114  private:
115  /** Internal data storage, do NOT modify! */
116  typedef struct {
117  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
118  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
119  } RestartInterpreterMessage_data_t;
120 
121  RestartInterpreterMessage_data_t *data;
122 
123  interface_enum_map_t enum_map_SkillStatusEnum;
124  public:
127 
129  /* Methods */
130  virtual Message * clone() const;
131  };
132 
133  class StopExecMessage : public Message
134  {
135  private:
136  /** Internal data storage, do NOT modify! */
137  typedef struct {
138  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
139  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
140  } StopExecMessage_data_t;
141 
142  StopExecMessage_data_t *data;
143 
144  interface_enum_map_t enum_map_SkillStatusEnum;
145  public:
146  StopExecMessage();
148 
149  explicit StopExecMessage(const StopExecMessage *m);
150  /* Methods */
151  virtual Message * clone() const;
152  };
153 
155  {
156  private:
157  /** Internal data storage, do NOT modify! */
158  typedef struct {
159  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
160  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
161  bool steal_control; /**<
162  If set to true steal the control from someone else who has it
163  atm. Use this with caution. But sometimes it is necessary to
164  ensure a successful operation, e.g. if the agent tries to
165  acquire control.
166  */
167  } AcquireControlMessage_data_t;
168 
169  AcquireControlMessage_data_t *data;
170 
171  interface_enum_map_t enum_map_SkillStatusEnum;
172  public:
173  AcquireControlMessage(const bool ini_steal_control);
176 
177  explicit AcquireControlMessage(const AcquireControlMessage *m);
178  /* Methods */
179  bool is_steal_control() const;
180  void set_steal_control(const bool new_steal_control);
181  size_t maxlenof_steal_control() const;
182  virtual Message * clone() const;
183  };
184 
186  {
187  private:
188  /** Internal data storage, do NOT modify! */
189  typedef struct {
190  int64_t timestamp_sec; /**< Interface Unix timestamp, seconds */
191  int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
192  } ReleaseControlMessage_data_t;
193 
194  ReleaseControlMessage_data_t *data;
195 
196  interface_enum_map_t enum_map_SkillStatusEnum;
197  public:
200 
201  explicit ReleaseControlMessage(const ReleaseControlMessage *m);
202  /* Methods */
203  virtual Message * clone() const;
204  };
205 
206  virtual bool message_valid(const Message *message) const;
207  private:
209  ~SkillerInterface();
210 
211  public:
212  /* Methods */
213  char * skill_string() const;
214  void set_skill_string(const char * new_skill_string);
215  size_t maxlenof_skill_string() const;
216  char * error() const;
217  void set_error(const char * new_error);
218  size_t maxlenof_error() const;
219  uint32_t exclusive_controller() const;
220  void set_exclusive_controller(const uint32_t new_exclusive_controller);
221  size_t maxlenof_exclusive_controller() const;
222  uint32_t msgid() const;
223  void set_msgid(const uint32_t new_msgid);
224  size_t maxlenof_msgid() const;
225  SkillStatusEnum status() const;
226  void set_status(const SkillStatusEnum new_status);
227  size_t maxlenof_status() const;
228  virtual Message * create_message(const char *type) const;
229 
230  virtual void copy_values(const Interface *other);
231  virtual const char * enum_tostring(const char *enumtype, int val) const;
232 
233 };
234 
235 } // end namespace fawkes
236 
237 #endif
fawkes::SkillerInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition: SkillerInterface.cpp:298
fawkes::SkillerInterface::set_exclusive_controller
void set_exclusive_controller(const uint32_t new_exclusive_controller)
Set exclusive_controller value.
Definition: SkillerInterface.cpp:198
fawkes::SkillerInterface::ReleaseControlMessage::~ReleaseControlMessage
~ReleaseControlMessage()
Destructor.
Definition: SkillerInterface.cpp:653
fawkes::SkillerInterface::RestartInterpreterMessage
RestartInterpreterMessage Fawkes BlackBoard Interface Message.
Definition: SkillerInterface.h:113
fawkes::SkillerInterface::StopExecMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:519
fawkes::SkillerInterface::AcquireControlMessage::set_steal_control
void set_steal_control(const bool new_steal_control)
Set steal_control value.
Definition: SkillerInterface.cpp:616
fawkes::SkillerInterface::tostring_SkillStatusEnum
const char * tostring_SkillStatusEnum(SkillStatusEnum value) const
Convert SkillStatusEnum constant to string.
Definition: SkillerInterface.cpp:84
fawkes::SkillerInterface::AcquireControlMessage::is_steal_control
bool is_steal_control() const
Get steal_control value.
Definition: SkillerInterface.cpp:591
fawkes::SkillerInterface::RestartInterpreterMessage::RestartInterpreterMessage
RestartInterpreterMessage()
Constructor.
Definition: SkillerInterface.cpp:431
fawkes::SkillerInterface::S_RUNNING
@ S_RUNNING
The execution is still running.
Definition: SkillerInterface.h:47
fawkes::Message
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:45
fawkes::SkillerInterface::ExecSkillMessage::maxlenof_skill_string
size_t maxlenof_skill_string() const
Get maximum length of skill_string value.
Definition: SkillerInterface.cpp:395
fawkes::SkillerInterface::ReleaseControlMessage
ReleaseControlMessage Fawkes BlackBoard Interface Message.
Definition: SkillerInterface.h:186
fawkes::SkillerInterface::set_msgid
void set_msgid(const uint32_t new_msgid)
Set msgid value.
Definition: SkillerInterface.cpp:234
fawkes::SkillerInterface::ExecSkillMessage::ExecSkillMessage
ExecSkillMessage()
Constructor.
Definition: SkillerInterface.cpp:344
fawkes::SkillerInterface::maxlenof_skill_string
size_t maxlenof_skill_string() const
Get maximum length of skill_string value.
Definition: SkillerInterface.cpp:113
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition: interface.cpp:643
fawkes::SkillerInterface::ReleaseControlMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:677
fawkes::SkillerInterface::maxlenof_error
size_t maxlenof_error() const
Get maximum length of error value.
Definition: SkillerInterface.cpp:148
fawkes::SkillerInterface::SkillStatusEnum
SkillStatusEnum
This determines the current status of skill execution.
Definition: SkillerInterface.h:44
fawkes::SkillerInterface::maxlenof_exclusive_controller
size_t maxlenof_exclusive_controller() const
Get maximum length of exclusive_controller value.
Definition: SkillerInterface.cpp:184
fawkes::SkillerInterface::S_FINAL
@ S_FINAL
The skill string has been successfully processed.
Definition: SkillerInterface.h:46
fawkes::SkillerInterface::RestartInterpreterMessage::~RestartInterpreterMessage
~RestartInterpreterMessage()
Destructor.
Definition: SkillerInterface.cpp:445
fawkes::SkillerInterface::AcquireControlMessage
AcquireControlMessage Fawkes BlackBoard Interface Message.
Definition: SkillerInterface.h:155
fawkes::SkillerInterface::set_error
void set_error(const char *new_error)
Set error value.
Definition: SkillerInterface.cpp:160
fawkes::SkillerInterface::ExecSkillMessage
ExecSkillMessage Fawkes BlackBoard Interface Message.
Definition: SkillerInterface.h:84
fawkes::SkillerInterface::StopExecMessage
StopExecMessage Fawkes BlackBoard Interface Message.
Definition: SkillerInterface.h:134
fawkes::SkillerInterface::set_status
void set_status(const SkillStatusEnum new_status)
Set status value.
Definition: SkillerInterface.cpp:268
fawkes::SkillerInterface::S_FAILED
@ S_FAILED
The execution failed and cannot succeed anymore.
Definition: SkillerInterface.h:48
fawkes
Fawkes library namespace.
fawkes::SkillerInterface::status
SkillStatusEnum status() const
Get status value.
Definition: SkillerInterface.cpp:246
fawkes::SkillerInterface::ExecSkillMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:419
fawkes::SkillerInterface::AcquireControlMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:627
fawkes::Interface
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
fawkes::SkillerInterface::msgid
uint32_t msgid() const
Get msgid value.
Definition: SkillerInterface.cpp:211
fawkes::SkillerInterface::create_message
virtual Message * create_message(const char *type) const
Create message based on type name.
Definition: SkillerInterface.cpp:275
fawkes::SkillerInterface::ExecSkillMessage::~ExecSkillMessage
~ExecSkillMessage()
Destructor.
Definition: SkillerInterface.cpp:359
fawkes::SkillerInterface::AcquireControlMessage::AcquireControlMessage
AcquireControlMessage()
Constructor.
Definition: SkillerInterface.cpp:548
fawkes::SkillerInterface
SkillerInterface Fawkes BlackBoard Interface.
Definition: SkillerInterface.h:34
fawkes::interface_enum_map_t
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:54
fawkes::SkillerInterface::skill_string
char * skill_string() const
Get skill_string value.
Definition: SkillerInterface.cpp:103
fawkes::SkillerInterface::ExecSkillMessage::skill_string
char * skill_string() const
Get skill_string value.
Definition: SkillerInterface.cpp:385
fawkes::SkillerInterface::error
char * error() const
Get error value.
Definition: SkillerInterface.cpp:138
fawkes::SkillerInterface::maxlenof_status
size_t maxlenof_status() const
Get maximum length of status value.
Definition: SkillerInterface.cpp:256
fawkes::SkillerInterface::set_skill_string
void set_skill_string(const char *new_skill_string)
Set skill_string value.
Definition: SkillerInterface.cpp:126
fawkes::SkillerInterface::ReleaseControlMessage::ReleaseControlMessage
ReleaseControlMessage()
Constructor.
Definition: SkillerInterface.cpp:639
fawkes::SkillerInterface::ExecSkillMessage::set_skill_string
void set_skill_string(const char *new_skill_string)
Set skill_string value.
Definition: SkillerInterface.cpp:408
fawkes::SkillerInterface::AcquireControlMessage::~AcquireControlMessage
~AcquireControlMessage()
Destructor.
Definition: SkillerInterface.cpp:563
fawkes::SkillerInterface::exclusive_controller
uint32_t exclusive_controller() const
Get exclusive_controller value.
Definition: SkillerInterface.cpp:174
fawkes::SkillerInterface::AcquireControlMessage::maxlenof_steal_control
size_t maxlenof_steal_control() const
Get maximum length of steal_control value.
Definition: SkillerInterface.cpp:601
fawkes::SkillerInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Convert arbitrary enum value to string.
Definition: SkillerInterface.cpp:309
fawkes::SkillerInterface::StopExecMessage::~StopExecMessage
~StopExecMessage()
Destructor.
Definition: SkillerInterface.cpp:495
fawkes::SkillerInterface::RestartInterpreterMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:469
fawkes::SkillerInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: SkillerInterface.cpp:686
fawkes::SkillerInterface::maxlenof_msgid
size_t maxlenof_msgid() const
Get maximum length of msgid value.
Definition: SkillerInterface.cpp:221
fawkes::SkillerInterface::StopExecMessage::StopExecMessage
StopExecMessage()
Constructor.
Definition: SkillerInterface.cpp:481
fawkes::SkillerInterface::S_INACTIVE
@ S_INACTIVE
No skill is running.
Definition: SkillerInterface.h:45