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 00051 private: 00052 /** Internal data storage, do NOT modify! */ 00053 typedef struct { 00054 unsigned int exclusive_controller; /**< 00055 Instance serial of the exclusive controller of the skiller. If this does not 00056 carry your instance serial your exec messages will be ignored. Aquire control with 00057 the AquireControlMessage. Make sure you release control before exiting. 00058 */ 00059 bool continuous; /**< 00060 True if continuous execution is in progress, false if no skill string is executed 00061 at all or it is executed one-shot with ExecSkillMessage. 00062 */ 00063 char skill_string[1024]; /**< 00064 Currently executed skill string, at least the first 1023 bytes of it. 00065 Must be properly null-terminated. 00066 */ 00067 char error[128]; /**< 00068 String describing the error. Can be set by a skill when it fails. 00069 */ 00070 SkillStatusEnum status; /**< 00071 The status of the current skill execution. 00072 */ 00073 } SkillerInterface_data_t; 00074 00075 SkillerInterface_data_t *data; 00076 00077 public: 00078 /* messages */ 00079 class ExecSkillMessage : public Message 00080 { 00081 private: 00082 /** Internal data storage, do NOT modify! */ 00083 typedef struct { 00084 char skill_string[1024]; /**< 00085 Currently executed skill string, at least the first 1023 bytes of it. 00086 Must be properly null-terminated. 00087 */ 00088 } ExecSkillMessage_data_t; 00089 00090 ExecSkillMessage_data_t *data; 00091 00092 public: 00093 ExecSkillMessage(const char * ini_skill_string); 00094 ExecSkillMessage(); 00095 ~ExecSkillMessage(); 00096 00097 ExecSkillMessage(const ExecSkillMessage *m); 00098 /* Methods */ 00099 char * skill_string() const; 00100 void set_skill_string(const char * new_skill_string); 00101 size_t maxlenof_skill_string() const; 00102 virtual Message * clone() const; 00103 }; 00104 00105 class ExecSkillContinuousMessage : public Message 00106 { 00107 private: 00108 /** Internal data storage, do NOT modify! */ 00109 typedef struct { 00110 char skill_string[1024]; /**< 00111 Currently executed skill string, at least the first 1023 bytes of it. 00112 Must be properly null-terminated. 00113 */ 00114 } ExecSkillContinuousMessage_data_t; 00115 00116 ExecSkillContinuousMessage_data_t *data; 00117 00118 public: 00119 ExecSkillContinuousMessage(const char * ini_skill_string); 00120 ExecSkillContinuousMessage(); 00121 ~ExecSkillContinuousMessage(); 00122 00123 ExecSkillContinuousMessage(const ExecSkillContinuousMessage *m); 00124 /* Methods */ 00125 char * skill_string() const; 00126 void set_skill_string(const char * new_skill_string); 00127 size_t maxlenof_skill_string() const; 00128 virtual Message * clone() const; 00129 }; 00130 00131 class RestartInterpreterMessage : public Message 00132 { 00133 public: 00134 RestartInterpreterMessage(); 00135 ~RestartInterpreterMessage(); 00136 00137 RestartInterpreterMessage(const RestartInterpreterMessage *m); 00138 /* Methods */ 00139 virtual Message * clone() const; 00140 }; 00141 00142 class StopExecMessage : public Message 00143 { 00144 public: 00145 StopExecMessage(); 00146 ~StopExecMessage(); 00147 00148 StopExecMessage(const StopExecMessage *m); 00149 /* Methods */ 00150 virtual Message * clone() const; 00151 }; 00152 00153 class AcquireControlMessage : public Message 00154 { 00155 public: 00156 AcquireControlMessage(); 00157 ~AcquireControlMessage(); 00158 00159 AcquireControlMessage(const AcquireControlMessage *m); 00160 /* Methods */ 00161 virtual Message * clone() const; 00162 }; 00163 00164 class ReleaseControlMessage : public Message 00165 { 00166 public: 00167 ReleaseControlMessage(); 00168 ~ReleaseControlMessage(); 00169 00170 ReleaseControlMessage(const ReleaseControlMessage *m); 00171 /* Methods */ 00172 virtual Message * clone() const; 00173 }; 00174 00175 virtual bool message_valid(const Message *message) const; 00176 private: 00177 SkillerInterface(); 00178 ~SkillerInterface(); 00179 00180 public: 00181 /* Methods */ 00182 char * skill_string() const; 00183 void set_skill_string(const char * new_skill_string); 00184 size_t maxlenof_skill_string() const; 00185 char * error() const; 00186 void set_error(const char * new_error); 00187 size_t maxlenof_error() const; 00188 unsigned int exclusive_controller() const; 00189 void set_exclusive_controller(const unsigned int new_exclusive_controller); 00190 size_t maxlenof_exclusive_controller() const; 00191 SkillStatusEnum status() const; 00192 void set_status(const SkillStatusEnum new_status); 00193 size_t maxlenof_status() const; 00194 bool is_continuous() const; 00195 void set_continuous(const bool new_continuous); 00196 size_t maxlenof_continuous() const; 00197 virtual Message * create_message(const char *type) const; 00198 00199 virtual void copy_values(const Interface *other); 00200 00201 }; 00202 00203 } // end namespace fawkes 00204 00205 #endif

