Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * SkillerInterface.cpp - 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 #include <interfaces/SkillerInterface.h> 00025 00026 #include <core/exceptions/software.h> 00027 00028 #include <cstring> 00029 #include <cstdlib> 00030 00031 namespace fawkes { 00032 00033 /** @class SkillerInterface <interfaces/SkillerInterface.h> 00034 * SkillerInterface Fawkes BlackBoard Interface. 00035 * 00036 The interface provides access to the skill execution runtime plugin. 00037 It provides basic status information about skiller and allows for 00038 calling skills via messages. It can also be used to manually restart 00039 the Lua interpreter if something is wedged. 00040 00041 * @ingroup FawkesInterfaces 00042 */ 00043 00044 00045 00046 /** Constructor */ 00047 SkillerInterface::SkillerInterface() : Interface() 00048 { 00049 data_size = sizeof(SkillerInterface_data_t); 00050 data_ptr = malloc(data_size); 00051 data = (SkillerInterface_data_t *)data_ptr; 00052 data_ts = (interface_data_ts_t *)data_ptr; 00053 memset(data_ptr, 0, data_size); 00054 add_fieldinfo(IFT_STRING, "skill_string", 1024, data->skill_string); 00055 add_fieldinfo(IFT_STRING, "error", 128, data->error); 00056 add_fieldinfo(IFT_UINT32, "exclusive_controller", 1, &data->exclusive_controller); 00057 add_fieldinfo(IFT_ENUM, "status", 1, &data->status, "SkillStatusEnum"); 00058 add_fieldinfo(IFT_BOOL, "continuous", 1, &data->continuous); 00059 add_messageinfo("ExecSkillMessage"); 00060 add_messageinfo("ExecSkillContinuousMessage"); 00061 add_messageinfo("RestartInterpreterMessage"); 00062 add_messageinfo("StopExecMessage"); 00063 add_messageinfo("AcquireControlMessage"); 00064 add_messageinfo("ReleaseControlMessage"); 00065 unsigned char tmp_hash[] = {0x7c, 0x85, 0xf3, 0x24, 0xea, 0x55, 0x50, 0xa1, 0x6c, 0xdb, 0xdc, 0x4b, 0x40, 0xba, 0xa1, 0xda}; 00066 set_hash(tmp_hash); 00067 } 00068 00069 /** Destructor */ 00070 SkillerInterface::~SkillerInterface() 00071 { 00072 free(data_ptr); 00073 } 00074 /** Convert SkillStatusEnum constant to string. 00075 * @param value value to convert to string 00076 * @return constant value as string. 00077 */ 00078 const char * 00079 SkillerInterface::tostring_SkillStatusEnum(SkillStatusEnum value) const 00080 { 00081 switch (value) { 00082 case S_INACTIVE: return "S_INACTIVE"; 00083 case S_FINAL: return "S_FINAL"; 00084 case S_RUNNING: return "S_RUNNING"; 00085 case S_FAILED: return "S_FAILED"; 00086 default: return "UNKNOWN"; 00087 } 00088 } 00089 /* Methods */ 00090 /** Get skill_string value. 00091 * 00092 Currently executed skill string, at least the first 1023 bytes of it. 00093 Must be properly null-terminated. 00094 00095 * @return skill_string value 00096 */ 00097 char * 00098 SkillerInterface::skill_string() const 00099 { 00100 return data->skill_string; 00101 } 00102 00103 /** Get maximum length of skill_string value. 00104 * @return length of skill_string value, can be length of the array or number of 00105 * maximum number of characters for a string 00106 */ 00107 size_t 00108 SkillerInterface::maxlenof_skill_string() const 00109 { 00110 return 1024; 00111 } 00112 00113 /** Set skill_string value. 00114 * 00115 Currently executed skill string, at least the first 1023 bytes of it. 00116 Must be properly null-terminated. 00117 00118 * @param new_skill_string new skill_string value 00119 */ 00120 void 00121 SkillerInterface::set_skill_string(const char * new_skill_string) 00122 { 00123 strncpy(data->skill_string, new_skill_string, sizeof(data->skill_string)); 00124 data_changed = true; 00125 } 00126 00127 /** Get error value. 00128 * 00129 String describing the error. Can be set by a skill when it fails. 00130 00131 * @return error value 00132 */ 00133 char * 00134 SkillerInterface::error() const 00135 { 00136 return data->error; 00137 } 00138 00139 /** Get maximum length of error value. 00140 * @return length of error value, can be length of the array or number of 00141 * maximum number of characters for a string 00142 */ 00143 size_t 00144 SkillerInterface::maxlenof_error() const 00145 { 00146 return 128; 00147 } 00148 00149 /** Set error value. 00150 * 00151 String describing the error. Can be set by a skill when it fails. 00152 00153 * @param new_error new error value 00154 */ 00155 void 00156 SkillerInterface::set_error(const char * new_error) 00157 { 00158 strncpy(data->error, new_error, sizeof(data->error)); 00159 data_changed = true; 00160 } 00161 00162 /** Get exclusive_controller value. 00163 * 00164 Instance serial of the exclusive controller of the skiller. If this does not 00165 carry your instance serial your exec messages will be ignored. Aquire control with 00166 the AquireControlMessage. Make sure you release control before exiting. 00167 00168 * @return exclusive_controller value 00169 */ 00170 uint32_t 00171 SkillerInterface::exclusive_controller() const 00172 { 00173 return data->exclusive_controller; 00174 } 00175 00176 /** Get maximum length of exclusive_controller value. 00177 * @return length of exclusive_controller value, can be length of the array or number of 00178 * maximum number of characters for a string 00179 */ 00180 size_t 00181 SkillerInterface::maxlenof_exclusive_controller() const 00182 { 00183 return 1; 00184 } 00185 00186 /** Set exclusive_controller value. 00187 * 00188 Instance serial of the exclusive controller of the skiller. If this does not 00189 carry your instance serial your exec messages will be ignored. Aquire control with 00190 the AquireControlMessage. Make sure you release control before exiting. 00191 00192 * @param new_exclusive_controller new exclusive_controller value 00193 */ 00194 void 00195 SkillerInterface::set_exclusive_controller(const uint32_t new_exclusive_controller) 00196 { 00197 data->exclusive_controller = new_exclusive_controller; 00198 data_changed = true; 00199 } 00200 00201 /** Get status value. 00202 * 00203 The status of the current skill execution. 00204 00205 * @return status value 00206 */ 00207 SkillerInterface::SkillStatusEnum 00208 SkillerInterface::status() const 00209 { 00210 return (SkillerInterface::SkillStatusEnum)data->status; 00211 } 00212 00213 /** Get maximum length of status value. 00214 * @return length of status value, can be length of the array or number of 00215 * maximum number of characters for a string 00216 */ 00217 size_t 00218 SkillerInterface::maxlenof_status() const 00219 { 00220 return 1; 00221 } 00222 00223 /** Set status value. 00224 * 00225 The status of the current skill execution. 00226 00227 * @param new_status new status value 00228 */ 00229 void 00230 SkillerInterface::set_status(const SkillStatusEnum new_status) 00231 { 00232 data->status = new_status; 00233 data_changed = true; 00234 } 00235 00236 /** Get continuous value. 00237 * 00238 True if continuous execution is in progress, false if no skill string is executed 00239 at all or it is executed one-shot with ExecSkillMessage. 00240 00241 * @return continuous value 00242 */ 00243 bool 00244 SkillerInterface::is_continuous() const 00245 { 00246 return data->continuous; 00247 } 00248 00249 /** Get maximum length of continuous value. 00250 * @return length of continuous value, can be length of the array or number of 00251 * maximum number of characters for a string 00252 */ 00253 size_t 00254 SkillerInterface::maxlenof_continuous() const 00255 { 00256 return 1; 00257 } 00258 00259 /** Set continuous value. 00260 * 00261 True if continuous execution is in progress, false if no skill string is executed 00262 at all or it is executed one-shot with ExecSkillMessage. 00263 00264 * @param new_continuous new continuous value 00265 */ 00266 void 00267 SkillerInterface::set_continuous(const bool new_continuous) 00268 { 00269 data->continuous = new_continuous; 00270 data_changed = true; 00271 } 00272 00273 /* =========== message create =========== */ 00274 Message * 00275 SkillerInterface::create_message(const char *type) const 00276 { 00277 if ( strncmp("ExecSkillMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00278 return new ExecSkillMessage(); 00279 } else if ( strncmp("ExecSkillContinuousMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00280 return new ExecSkillContinuousMessage(); 00281 } else if ( strncmp("RestartInterpreterMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00282 return new RestartInterpreterMessage(); 00283 } else if ( strncmp("StopExecMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00284 return new StopExecMessage(); 00285 } else if ( strncmp("AcquireControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00286 return new AcquireControlMessage(); 00287 } else if ( strncmp("ReleaseControlMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) { 00288 return new ReleaseControlMessage(); 00289 } else { 00290 throw UnknownTypeException("The given type '%s' does not match any known " 00291 "message type for this interface type.", type); 00292 } 00293 } 00294 00295 00296 /** Copy values from other interface. 00297 * @param other other interface to copy values from 00298 */ 00299 void 00300 SkillerInterface::copy_values(const Interface *other) 00301 { 00302 const SkillerInterface *oi = dynamic_cast<const SkillerInterface *>(other); 00303 if (oi == NULL) { 00304 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)", 00305 type(), other->type()); 00306 } 00307 memcpy(data, oi->data, sizeof(SkillerInterface_data_t)); 00308 } 00309 00310 const char * 00311 SkillerInterface::enum_tostring(const char *enumtype, int val) const 00312 { 00313 if (strcmp(enumtype, "SkillStatusEnum") == 0) { 00314 return tostring_SkillStatusEnum((SkillStatusEnum)val); 00315 } 00316 throw UnknownTypeException("Unknown enum type %s", enumtype); 00317 } 00318 00319 /* =========== messages =========== */ 00320 /** @class SkillerInterface::ExecSkillMessage <interfaces/SkillerInterface.h> 00321 * ExecSkillMessage Fawkes BlackBoard Interface Message. 00322 * 00323 00324 */ 00325 00326 00327 /** Constructor with initial values. 00328 * @param ini_skill_string initial value for skill_string 00329 */ 00330 SkillerInterface::ExecSkillMessage::ExecSkillMessage(const char * ini_skill_string) : Message("ExecSkillMessage") 00331 { 00332 data_size = sizeof(ExecSkillMessage_data_t); 00333 data_ptr = malloc(data_size); 00334 memset(data_ptr, 0, data_size); 00335 data = (ExecSkillMessage_data_t *)data_ptr; 00336 data_ts = (message_data_ts_t *)data_ptr; 00337 strncpy(data->skill_string, ini_skill_string, 1024); 00338 add_fieldinfo(IFT_STRING, "skill_string", 1024, data->skill_string); 00339 } 00340 /** Constructor */ 00341 SkillerInterface::ExecSkillMessage::ExecSkillMessage() : Message("ExecSkillMessage") 00342 { 00343 data_size = sizeof(ExecSkillMessage_data_t); 00344 data_ptr = malloc(data_size); 00345 memset(data_ptr, 0, data_size); 00346 data = (ExecSkillMessage_data_t *)data_ptr; 00347 data_ts = (message_data_ts_t *)data_ptr; 00348 add_fieldinfo(IFT_STRING, "skill_string", 1024, data->skill_string); 00349 } 00350 00351 /** Destructor */ 00352 SkillerInterface::ExecSkillMessage::~ExecSkillMessage() 00353 { 00354 free(data_ptr); 00355 } 00356 00357 /** Copy constructor. 00358 * @param m message to copy from 00359 */ 00360 SkillerInterface::ExecSkillMessage::ExecSkillMessage(const ExecSkillMessage *m) : Message("ExecSkillMessage") 00361 { 00362 data_size = m->data_size; 00363 data_ptr = malloc(data_size); 00364 memcpy(data_ptr, m->data_ptr, data_size); 00365 data = (ExecSkillMessage_data_t *)data_ptr; 00366 data_ts = (message_data_ts_t *)data_ptr; 00367 } 00368 00369 /* Methods */ 00370 /** Get skill_string value. 00371 * 00372 Currently executed skill string, at least the first 1023 bytes of it. 00373 Must be properly null-terminated. 00374 00375 * @return skill_string value 00376 */ 00377 char * 00378 SkillerInterface::ExecSkillMessage::skill_string() const 00379 { 00380 return data->skill_string; 00381 } 00382 00383 /** Get maximum length of skill_string value. 00384 * @return length of skill_string value, can be length of the array or number of 00385 * maximum number of characters for a string 00386 */ 00387 size_t 00388 SkillerInterface::ExecSkillMessage::maxlenof_skill_string() const 00389 { 00390 return 1024; 00391 } 00392 00393 /** Set skill_string value. 00394 * 00395 Currently executed skill string, at least the first 1023 bytes of it. 00396 Must be properly null-terminated. 00397 00398 * @param new_skill_string new skill_string value 00399 */ 00400 void 00401 SkillerInterface::ExecSkillMessage::set_skill_string(const char * new_skill_string) 00402 { 00403 strncpy(data->skill_string, new_skill_string, sizeof(data->skill_string)); 00404 } 00405 00406 /** Clone this message. 00407 * Produces a message of the same type as this message and copies the 00408 * data to the new message. 00409 * @return clone of this message 00410 */ 00411 Message * 00412 SkillerInterface::ExecSkillMessage::clone() const 00413 { 00414 return new SkillerInterface::ExecSkillMessage(this); 00415 } 00416 /** @class SkillerInterface::ExecSkillContinuousMessage <interfaces/SkillerInterface.h> 00417 * ExecSkillContinuousMessage Fawkes BlackBoard Interface Message. 00418 * 00419 00420 */ 00421 00422 00423 /** Constructor with initial values. 00424 * @param ini_skill_string initial value for skill_string 00425 */ 00426 SkillerInterface::ExecSkillContinuousMessage::ExecSkillContinuousMessage(const char * ini_skill_string) : Message("ExecSkillContinuousMessage") 00427 { 00428 data_size = sizeof(ExecSkillContinuousMessage_data_t); 00429 data_ptr = malloc(data_size); 00430 memset(data_ptr, 0, data_size); 00431 data = (ExecSkillContinuousMessage_data_t *)data_ptr; 00432 data_ts = (message_data_ts_t *)data_ptr; 00433 strncpy(data->skill_string, ini_skill_string, 1024); 00434 add_fieldinfo(IFT_STRING, "skill_string", 1024, data->skill_string); 00435 } 00436 /** Constructor */ 00437 SkillerInterface::ExecSkillContinuousMessage::ExecSkillContinuousMessage() : Message("ExecSkillContinuousMessage") 00438 { 00439 data_size = sizeof(ExecSkillContinuousMessage_data_t); 00440 data_ptr = malloc(data_size); 00441 memset(data_ptr, 0, data_size); 00442 data = (ExecSkillContinuousMessage_data_t *)data_ptr; 00443 data_ts = (message_data_ts_t *)data_ptr; 00444 add_fieldinfo(IFT_STRING, "skill_string", 1024, data->skill_string); 00445 } 00446 00447 /** Destructor */ 00448 SkillerInterface::ExecSkillContinuousMessage::~ExecSkillContinuousMessage() 00449 { 00450 free(data_ptr); 00451 } 00452 00453 /** Copy constructor. 00454 * @param m message to copy from 00455 */ 00456 SkillerInterface::ExecSkillContinuousMessage::ExecSkillContinuousMessage(const ExecSkillContinuousMessage *m) : Message("ExecSkillContinuousMessage") 00457 { 00458 data_size = m->data_size; 00459 data_ptr = malloc(data_size); 00460 memcpy(data_ptr, m->data_ptr, data_size); 00461 data = (ExecSkillContinuousMessage_data_t *)data_ptr; 00462 data_ts = (message_data_ts_t *)data_ptr; 00463 } 00464 00465 /* Methods */ 00466 /** Get skill_string value. 00467 * 00468 Currently executed skill string, at least the first 1023 bytes of it. 00469 Must be properly null-terminated. 00470 00471 * @return skill_string value 00472 */ 00473 char * 00474 SkillerInterface::ExecSkillContinuousMessage::skill_string() const 00475 { 00476 return data->skill_string; 00477 } 00478 00479 /** Get maximum length of skill_string value. 00480 * @return length of skill_string value, can be length of the array or number of 00481 * maximum number of characters for a string 00482 */ 00483 size_t 00484 SkillerInterface::ExecSkillContinuousMessage::maxlenof_skill_string() const 00485 { 00486 return 1024; 00487 } 00488 00489 /** Set skill_string value. 00490 * 00491 Currently executed skill string, at least the first 1023 bytes of it. 00492 Must be properly null-terminated. 00493 00494 * @param new_skill_string new skill_string value 00495 */ 00496 void 00497 SkillerInterface::ExecSkillContinuousMessage::set_skill_string(const char * new_skill_string) 00498 { 00499 strncpy(data->skill_string, new_skill_string, sizeof(data->skill_string)); 00500 } 00501 00502 /** Clone this message. 00503 * Produces a message of the same type as this message and copies the 00504 * data to the new message. 00505 * @return clone of this message 00506 */ 00507 Message * 00508 SkillerInterface::ExecSkillContinuousMessage::clone() const 00509 { 00510 return new SkillerInterface::ExecSkillContinuousMessage(this); 00511 } 00512 /** @class SkillerInterface::RestartInterpreterMessage <interfaces/SkillerInterface.h> 00513 * RestartInterpreterMessage Fawkes BlackBoard Interface Message. 00514 * 00515 00516 */ 00517 00518 00519 /** Constructor */ 00520 SkillerInterface::RestartInterpreterMessage::RestartInterpreterMessage() : Message("RestartInterpreterMessage") 00521 { 00522 data_size = sizeof(RestartInterpreterMessage_data_t); 00523 data_ptr = malloc(data_size); 00524 memset(data_ptr, 0, data_size); 00525 data = (RestartInterpreterMessage_data_t *)data_ptr; 00526 data_ts = (message_data_ts_t *)data_ptr; 00527 } 00528 00529 /** Destructor */ 00530 SkillerInterface::RestartInterpreterMessage::~RestartInterpreterMessage() 00531 { 00532 free(data_ptr); 00533 } 00534 00535 /** Copy constructor. 00536 * @param m message to copy from 00537 */ 00538 SkillerInterface::RestartInterpreterMessage::RestartInterpreterMessage(const RestartInterpreterMessage *m) : Message("RestartInterpreterMessage") 00539 { 00540 data_size = m->data_size; 00541 data_ptr = malloc(data_size); 00542 memcpy(data_ptr, m->data_ptr, data_size); 00543 data = (RestartInterpreterMessage_data_t *)data_ptr; 00544 data_ts = (message_data_ts_t *)data_ptr; 00545 } 00546 00547 /* Methods */ 00548 /** Clone this message. 00549 * Produces a message of the same type as this message and copies the 00550 * data to the new message. 00551 * @return clone of this message 00552 */ 00553 Message * 00554 SkillerInterface::RestartInterpreterMessage::clone() const 00555 { 00556 return new SkillerInterface::RestartInterpreterMessage(this); 00557 } 00558 /** @class SkillerInterface::StopExecMessage <interfaces/SkillerInterface.h> 00559 * StopExecMessage Fawkes BlackBoard Interface Message. 00560 * 00561 00562 */ 00563 00564 00565 /** Constructor */ 00566 SkillerInterface::StopExecMessage::StopExecMessage() : Message("StopExecMessage") 00567 { 00568 data_size = sizeof(StopExecMessage_data_t); 00569 data_ptr = malloc(data_size); 00570 memset(data_ptr, 0, data_size); 00571 data = (StopExecMessage_data_t *)data_ptr; 00572 data_ts = (message_data_ts_t *)data_ptr; 00573 } 00574 00575 /** Destructor */ 00576 SkillerInterface::StopExecMessage::~StopExecMessage() 00577 { 00578 free(data_ptr); 00579 } 00580 00581 /** Copy constructor. 00582 * @param m message to copy from 00583 */ 00584 SkillerInterface::StopExecMessage::StopExecMessage(const StopExecMessage *m) : Message("StopExecMessage") 00585 { 00586 data_size = m->data_size; 00587 data_ptr = malloc(data_size); 00588 memcpy(data_ptr, m->data_ptr, data_size); 00589 data = (StopExecMessage_data_t *)data_ptr; 00590 data_ts = (message_data_ts_t *)data_ptr; 00591 } 00592 00593 /* Methods */ 00594 /** Clone this message. 00595 * Produces a message of the same type as this message and copies the 00596 * data to the new message. 00597 * @return clone of this message 00598 */ 00599 Message * 00600 SkillerInterface::StopExecMessage::clone() const 00601 { 00602 return new SkillerInterface::StopExecMessage(this); 00603 } 00604 /** @class SkillerInterface::AcquireControlMessage <interfaces/SkillerInterface.h> 00605 * AcquireControlMessage Fawkes BlackBoard Interface Message. 00606 * 00607 00608 */ 00609 00610 00611 /** Constructor */ 00612 SkillerInterface::AcquireControlMessage::AcquireControlMessage() : Message("AcquireControlMessage") 00613 { 00614 data_size = sizeof(AcquireControlMessage_data_t); 00615 data_ptr = malloc(data_size); 00616 memset(data_ptr, 0, data_size); 00617 data = (AcquireControlMessage_data_t *)data_ptr; 00618 data_ts = (message_data_ts_t *)data_ptr; 00619 } 00620 00621 /** Destructor */ 00622 SkillerInterface::AcquireControlMessage::~AcquireControlMessage() 00623 { 00624 free(data_ptr); 00625 } 00626 00627 /** Copy constructor. 00628 * @param m message to copy from 00629 */ 00630 SkillerInterface::AcquireControlMessage::AcquireControlMessage(const AcquireControlMessage *m) : Message("AcquireControlMessage") 00631 { 00632 data_size = m->data_size; 00633 data_ptr = malloc(data_size); 00634 memcpy(data_ptr, m->data_ptr, data_size); 00635 data = (AcquireControlMessage_data_t *)data_ptr; 00636 data_ts = (message_data_ts_t *)data_ptr; 00637 } 00638 00639 /* Methods */ 00640 /** Clone this message. 00641 * Produces a message of the same type as this message and copies the 00642 * data to the new message. 00643 * @return clone of this message 00644 */ 00645 Message * 00646 SkillerInterface::AcquireControlMessage::clone() const 00647 { 00648 return new SkillerInterface::AcquireControlMessage(this); 00649 } 00650 /** @class SkillerInterface::ReleaseControlMessage <interfaces/SkillerInterface.h> 00651 * ReleaseControlMessage Fawkes BlackBoard Interface Message. 00652 * 00653 00654 */ 00655 00656 00657 /** Constructor */ 00658 SkillerInterface::ReleaseControlMessage::ReleaseControlMessage() : Message("ReleaseControlMessage") 00659 { 00660 data_size = sizeof(ReleaseControlMessage_data_t); 00661 data_ptr = malloc(data_size); 00662 memset(data_ptr, 0, data_size); 00663 data = (ReleaseControlMessage_data_t *)data_ptr; 00664 data_ts = (message_data_ts_t *)data_ptr; 00665 } 00666 00667 /** Destructor */ 00668 SkillerInterface::ReleaseControlMessage::~ReleaseControlMessage() 00669 { 00670 free(data_ptr); 00671 } 00672 00673 /** Copy constructor. 00674 * @param m message to copy from 00675 */ 00676 SkillerInterface::ReleaseControlMessage::ReleaseControlMessage(const ReleaseControlMessage *m) : Message("ReleaseControlMessage") 00677 { 00678 data_size = m->data_size; 00679 data_ptr = malloc(data_size); 00680 memcpy(data_ptr, m->data_ptr, data_size); 00681 data = (ReleaseControlMessage_data_t *)data_ptr; 00682 data_ts = (message_data_ts_t *)data_ptr; 00683 } 00684 00685 /* Methods */ 00686 /** Clone this message. 00687 * Produces a message of the same type as this message and copies the 00688 * data to the new message. 00689 * @return clone of this message 00690 */ 00691 Message * 00692 SkillerInterface::ReleaseControlMessage::clone() const 00693 { 00694 return new SkillerInterface::ReleaseControlMessage(this); 00695 } 00696 /** Check if message is valid and can be enqueued. 00697 * @param message Message to check 00698 * @return true if the message is valid, false otherwise. 00699 */ 00700 bool 00701 SkillerInterface::message_valid(const Message *message) const 00702 { 00703 const ExecSkillMessage *m0 = dynamic_cast<const ExecSkillMessage *>(message); 00704 if ( m0 != NULL ) { 00705 return true; 00706 } 00707 const ExecSkillContinuousMessage *m1 = dynamic_cast<const ExecSkillContinuousMessage *>(message); 00708 if ( m1 != NULL ) { 00709 return true; 00710 } 00711 const RestartInterpreterMessage *m2 = dynamic_cast<const RestartInterpreterMessage *>(message); 00712 if ( m2 != NULL ) { 00713 return true; 00714 } 00715 const StopExecMessage *m3 = dynamic_cast<const StopExecMessage *>(message); 00716 if ( m3 != NULL ) { 00717 return true; 00718 } 00719 const AcquireControlMessage *m4 = dynamic_cast<const AcquireControlMessage *>(message); 00720 if ( m4 != NULL ) { 00721 return true; 00722 } 00723 const ReleaseControlMessage *m5 = dynamic_cast<const ReleaseControlMessage *>(message); 00724 if ( m5 != NULL ) { 00725 return true; 00726 } 00727 return false; 00728 } 00729 00730 /// @cond INTERNALS 00731 EXPORT_INTERFACE(SkillerInterface) 00732 /// @endcond 00733 00734 00735 } // end namespace fawkes