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 
33 class SkillerInterface : public Interface
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 
112  class RestartInterpreterMessage : public Message
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 
154  class AcquireControlMessage : public Message
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 
185  class ReleaseControlMessage : public Message
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:309
fawkes::SkillerInterface::set_exclusive_controller
void set_exclusive_controller(const uint32_t new_exclusive_controller)
Set exclusive_controller value.
Definition: SkillerInterface.cpp:206
fawkes::SkillerInterface::ReleaseControlMessage::~ReleaseControlMessage
~ReleaseControlMessage()
Destructor.
Definition: SkillerInterface.cpp:665
fawkes::SkillerInterface::RestartInterpreterMessage
Definition: SkillerInterface.h:121
fawkes::SkillerInterface::StopExecMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:531
fawkes::SkillerInterface::AcquireControlMessage::set_steal_control
void set_steal_control(const bool new_steal_control)
Set steal_control value.
Definition: SkillerInterface.cpp:628
fawkes::SkillerInterface::tostring_SkillStatusEnum
const char * tostring_SkillStatusEnum(SkillStatusEnum value) const
Convert SkillStatusEnum constant to string.
Definition: SkillerInterface.cpp:88
fawkes::SkillerInterface::AcquireControlMessage::is_steal_control
bool is_steal_control() const
Get steal_control value.
Definition: SkillerInterface.cpp:603
fawkes::SkillerInterface::RestartInterpreterMessage::RestartInterpreterMessage
RestartInterpreterMessage()
Constructor.
Definition: SkillerInterface.cpp:443
fawkes::SkillerInterface::S_RUNNING
The execution is still running.
Definition: SkillerInterface.h:61
fawkes::Message
Definition: message.h:40
fawkes::SkillerInterface::ExecSkillMessage::maxlenof_skill_string
size_t maxlenof_skill_string() const
Get maximum length of skill_string value.
Definition: SkillerInterface.cpp:406
fawkes::SkillerInterface::ReleaseControlMessage
Definition: SkillerInterface.h:194
fawkes::SkillerInterface::set_msgid
void set_msgid(const uint32_t new_msgid)
Set msgid value.
Definition: SkillerInterface.cpp:243
fawkes::SkillerInterface::ExecSkillMessage::ExecSkillMessage
ExecSkillMessage()
Constructor.
Definition: SkillerInterface.cpp:355
fawkes::SkillerInterface::maxlenof_skill_string
size_t maxlenof_skill_string() const
Get maximum length of skill_string value.
Definition: SkillerInterface.cpp:117
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:689
fawkes::SkillerInterface::maxlenof_error
size_t maxlenof_error() const
Get maximum length of error value.
Definition: SkillerInterface.cpp:154
fawkes::SkillerInterface::SkillStatusEnum
SkillStatusEnum
This determines the current status of skill execution.
Definition: SkillerInterface.h:53
fawkes::SkillerInterface::maxlenof_exclusive_controller
size_t maxlenof_exclusive_controller() const
Get maximum length of exclusive_controller value.
Definition: SkillerInterface.cpp:192
fawkes::SkillerInterface::S_FINAL
The skill string has been successfully processed.
Definition: SkillerInterface.h:60
fawkes::SkillerInterface::RestartInterpreterMessage::~RestartInterpreterMessage
~RestartInterpreterMessage()
Destructor.
Definition: SkillerInterface.cpp:457
fawkes::SkillerInterface::AcquireControlMessage
Definition: SkillerInterface.h:163
fawkes::SkillerInterface::set_error
void set_error(const char *new_error)
Set error value.
Definition: SkillerInterface.cpp:166
fawkes::SkillerInterface::ExecSkillMessage
Definition: SkillerInterface.h:92
fawkes::SkillerInterface::StopExecMessage
Definition: SkillerInterface.h:142
fawkes::SkillerInterface::set_status
void set_status(const SkillStatusEnum new_status)
Set status value.
Definition: SkillerInterface.cpp:278
fawkes::SkillerInterface::S_FAILED
The execution failed and cannot succeed anymore.
Definition: SkillerInterface.h:62
fawkes
fawkes::SkillerInterface::status
SkillStatusEnum status() const
Get status value.
Definition: SkillerInterface.cpp:256
fawkes::SkillerInterface::ExecSkillMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:431
fawkes::SkillerInterface::AcquireControlMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:639
fawkes::Interface
Definition: interface.h:77
fawkes::SkillerInterface::msgid
uint32_t msgid() const
Get msgid value.
Definition: SkillerInterface.cpp:220
fawkes::SkillerInterface::create_message
virtual Message * create_message(const char *type) const
Definition: SkillerInterface.cpp:286
fawkes::SkillerInterface::ExecSkillMessage::~ExecSkillMessage
~ExecSkillMessage()
Destructor.
Definition: SkillerInterface.cpp:370
fawkes::SkillerInterface::AcquireControlMessage::AcquireControlMessage
AcquireControlMessage()
Constructor.
Definition: SkillerInterface.cpp:560
fawkes::SkillerInterface
Definition: SkillerInterface.h:37
fawkes::interface_enum_map_t
std::map< int, std::string > interface_enum_map_t
Map of enum integer to string values.
Definition: types.h:59
fawkes::SkillerInterface::skill_string
char * skill_string() const
Get skill_string value.
Definition: SkillerInterface.cpp:107
fawkes::SkillerInterface::ExecSkillMessage::skill_string
char * skill_string() const
Get skill_string value.
Definition: SkillerInterface.cpp:396
fawkes::SkillerInterface::error
char * error() const
Get error value.
Definition: SkillerInterface.cpp:144
fawkes::SkillerInterface::maxlenof_status
size_t maxlenof_status() const
Get maximum length of status value.
Definition: SkillerInterface.cpp:266
fawkes::SkillerInterface::set_skill_string
void set_skill_string(const char *new_skill_string)
Set skill_string value.
Definition: SkillerInterface.cpp:130
fawkes::SkillerInterface::ReleaseControlMessage::ReleaseControlMessage
ReleaseControlMessage()
Constructor.
Definition: SkillerInterface.cpp:651
fawkes::SkillerInterface::ExecSkillMessage::set_skill_string
void set_skill_string(const char *new_skill_string)
Set skill_string value.
Definition: SkillerInterface.cpp:419
fawkes::SkillerInterface::AcquireControlMessage::~AcquireControlMessage
~AcquireControlMessage()
Destructor.
Definition: SkillerInterface.cpp:575
fawkes::SkillerInterface::exclusive_controller
uint32_t exclusive_controller() const
Get exclusive_controller value.
Definition: SkillerInterface.cpp:182
fawkes::SkillerInterface::AcquireControlMessage::maxlenof_steal_control
size_t maxlenof_steal_control() const
Get maximum length of steal_control value.
Definition: SkillerInterface.cpp:613
fawkes::SkillerInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Definition: SkillerInterface.cpp:320
fawkes::SkillerInterface::StopExecMessage::~StopExecMessage
~StopExecMessage()
Destructor.
Definition: SkillerInterface.cpp:507
fawkes::SkillerInterface::RestartInterpreterMessage::clone
virtual Message * clone() const
Clone this message.
Definition: SkillerInterface.cpp:481
fawkes::SkillerInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition: SkillerInterface.cpp:698
fawkes::SkillerInterface::maxlenof_msgid
size_t maxlenof_msgid() const
Get maximum length of msgid value.
Definition: SkillerInterface.cpp:230
fawkes::SkillerInterface::StopExecMessage::StopExecMessage
StopExecMessage()
Constructor.
Definition: SkillerInterface.cpp:493
fawkes::SkillerInterface::S_INACTIVE
No skill is running.
Definition: SkillerInterface.h:59