Fawkes API Fawkes Development Version

SkillerInterface.h

00001 
00002 /***************************************************************************
00003  *  SkillerInterface.h - Fawkes BlackBoard Interface - SkillerInterface
00004  *
00005  *  Templated created:   Thu Oct 12 10:49:19 2006
00006  *  Copyright  2008  Tim Niemueller
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. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __INTERFACES_SKILLERINTERFACE_H_
00025 #define __INTERFACES_SKILLERINTERFACE_H_
00026 
00027 #include <interface/interface.h>
00028 #include <interface/message.h>
00029 #include <interface/field_iterator.h>
00030 
00031 namespace fawkes {
00032 
00033 class SkillerInterface : public Interface
00034 {
00035  /// @cond INTERNALS
00036  INTERFACE_MGMT_FRIENDS(SkillerInterface)
00037  /// @endcond
00038  public:
00039   /* constants */
00040 
00041   /** 
00042         This determines the current status of skill execution.
00043        */
00044   typedef enum {
00045     S_INACTIVE /**< No skill is running. */,
00046     S_FINAL /**< The skill string has been successfully processed. */,
00047     S_RUNNING /**< The execution is still running. */,
00048     S_FAILED /**< The execution failed and cannot succeed anymore. */
00049   } SkillStatusEnum;
00050   const char * tostring_SkillStatusEnum(SkillStatusEnum value) const;
00051 
00052  private:
00053 #pragma pack(push,4)
00054   /** Internal data storage, do NOT modify! */
00055   typedef struct {
00056     int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00057     int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00058     char skill_string[1024]; /**< 
00059       Currently executed skill string, at least the first 1023 bytes of it.
00060       Must be properly null-terminated.
00061      */
00062     char error[128]; /**< 
00063       String describing the error. Can be set by a skill when it fails.
00064      */
00065     uint32_t exclusive_controller; /**< 
00066       Instance serial of the exclusive controller of the skiller. If this does not
00067       carry your instance serial your exec messages will be ignored. Aquire control with
00068       the AquireControlMessage. Make sure you release control before exiting.
00069      */
00070     SkillStatusEnum status; /**< 
00071       The status of the current skill execution.
00072      */
00073     bool continuous; /**< 
00074       True if continuous execution is in progress, false if no skill string is executed
00075       at all or it is executed one-shot with ExecSkillMessage.
00076      */
00077   } SkillerInterface_data_t;
00078 #pragma pack(pop)
00079 
00080   SkillerInterface_data_t *data;
00081 
00082  public:
00083   /* messages */
00084   class ExecSkillMessage : public Message
00085   {
00086    private:
00087 #pragma pack(push,4)
00088     /** Internal data storage, do NOT modify! */
00089     typedef struct {
00090       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00091       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00092       char skill_string[1024]; /**< 
00093       Currently executed skill string, at least the first 1023 bytes of it.
00094       Must be properly null-terminated.
00095      */
00096     } ExecSkillMessage_data_t;
00097 #pragma pack(pop)
00098 
00099     ExecSkillMessage_data_t *data;
00100 
00101    public:
00102     ExecSkillMessage(const char * ini_skill_string);
00103     ExecSkillMessage();
00104     ~ExecSkillMessage();
00105 
00106     ExecSkillMessage(const ExecSkillMessage *m);
00107     /* Methods */
00108     char * skill_string() const;
00109     void set_skill_string(const char * new_skill_string);
00110     size_t maxlenof_skill_string() const;
00111     virtual Message * clone() const;
00112   };
00113 
00114   class ExecSkillContinuousMessage : public Message
00115   {
00116    private:
00117 #pragma pack(push,4)
00118     /** Internal data storage, do NOT modify! */
00119     typedef struct {
00120       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00121       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00122       char skill_string[1024]; /**< 
00123       Currently executed skill string, at least the first 1023 bytes of it.
00124       Must be properly null-terminated.
00125      */
00126     } ExecSkillContinuousMessage_data_t;
00127 #pragma pack(pop)
00128 
00129     ExecSkillContinuousMessage_data_t *data;
00130 
00131    public:
00132     ExecSkillContinuousMessage(const char * ini_skill_string);
00133     ExecSkillContinuousMessage();
00134     ~ExecSkillContinuousMessage();
00135 
00136     ExecSkillContinuousMessage(const ExecSkillContinuousMessage *m);
00137     /* Methods */
00138     char * skill_string() const;
00139     void set_skill_string(const char * new_skill_string);
00140     size_t maxlenof_skill_string() const;
00141     virtual Message * clone() const;
00142   };
00143 
00144   class RestartInterpreterMessage : public Message
00145   {
00146    private:
00147 #pragma pack(push,4)
00148     /** Internal data storage, do NOT modify! */
00149     typedef struct {
00150       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00151       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00152     } RestartInterpreterMessage_data_t;
00153 #pragma pack(pop)
00154 
00155     RestartInterpreterMessage_data_t *data;
00156 
00157    public:
00158     RestartInterpreterMessage();
00159     ~RestartInterpreterMessage();
00160 
00161     RestartInterpreterMessage(const RestartInterpreterMessage *m);
00162     /* Methods */
00163     virtual Message * clone() const;
00164   };
00165 
00166   class StopExecMessage : public Message
00167   {
00168    private:
00169 #pragma pack(push,4)
00170     /** Internal data storage, do NOT modify! */
00171     typedef struct {
00172       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00173       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00174     } StopExecMessage_data_t;
00175 #pragma pack(pop)
00176 
00177     StopExecMessage_data_t *data;
00178 
00179    public:
00180     StopExecMessage();
00181     ~StopExecMessage();
00182 
00183     StopExecMessage(const StopExecMessage *m);
00184     /* Methods */
00185     virtual Message * clone() const;
00186   };
00187 
00188   class AcquireControlMessage : public Message
00189   {
00190    private:
00191 #pragma pack(push,4)
00192     /** Internal data storage, do NOT modify! */
00193     typedef struct {
00194       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00195       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00196     } AcquireControlMessage_data_t;
00197 #pragma pack(pop)
00198 
00199     AcquireControlMessage_data_t *data;
00200 
00201    public:
00202     AcquireControlMessage();
00203     ~AcquireControlMessage();
00204 
00205     AcquireControlMessage(const AcquireControlMessage *m);
00206     /* Methods */
00207     virtual Message * clone() const;
00208   };
00209 
00210   class ReleaseControlMessage : public Message
00211   {
00212    private:
00213 #pragma pack(push,4)
00214     /** Internal data storage, do NOT modify! */
00215     typedef struct {
00216       int64_t timestamp_sec;  /**< Interface Unix timestamp, seconds */
00217       int64_t timestamp_usec; /**< Interface Unix timestamp, micro-seconds */
00218     } ReleaseControlMessage_data_t;
00219 #pragma pack(pop)
00220 
00221     ReleaseControlMessage_data_t *data;
00222 
00223    public:
00224     ReleaseControlMessage();
00225     ~ReleaseControlMessage();
00226 
00227     ReleaseControlMessage(const ReleaseControlMessage *m);
00228     /* Methods */
00229     virtual Message * clone() const;
00230   };
00231 
00232   virtual bool message_valid(const Message *message) const;
00233  private:
00234   SkillerInterface();
00235   ~SkillerInterface();
00236 
00237  public:
00238   /* Methods */
00239   char * skill_string() const;
00240   void set_skill_string(const char * new_skill_string);
00241   size_t maxlenof_skill_string() const;
00242   char * error() const;
00243   void set_error(const char * new_error);
00244   size_t maxlenof_error() const;
00245   uint32_t exclusive_controller() const;
00246   void set_exclusive_controller(const uint32_t new_exclusive_controller);
00247   size_t maxlenof_exclusive_controller() const;
00248   SkillStatusEnum status() const;
00249   void set_status(const SkillStatusEnum new_status);
00250   size_t maxlenof_status() const;
00251   bool is_continuous() const;
00252   void set_continuous(const bool new_continuous);
00253   size_t maxlenof_continuous() const;
00254   virtual Message * create_message(const char *type) const;
00255 
00256   virtual void copy_values(const Interface *other);
00257   virtual const char * enum_tostring(const char *enumtype, int val) const;
00258 
00259 };
00260 
00261 } // end namespace fawkes
00262 
00263 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends