00001 /* 00002 SagaEngine library 00003 Copyright (c) 2002-2006 Skalden Studio AS 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any 00007 damages arising from the use of this software. 00008 00009 Permission is granted to distribute the library under the terms of the 00010 Q Public License version 1.0. Be sure to read and understand the license 00011 before using the library. It should be included here, or you may read it 00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl 00013 00014 The original version of this library can be located at: 00015 http://www.sagaengine.com/ 00016 00017 Rune Myrland 00018 rune@skalden.com 00019 */ 00020 00021 00022 #ifndef ActionAndParameter_hpp 00023 #define ActionAndParameter_hpp 00024 00025 #include "Action.hpp" 00026 #include "../thing/sim_thing.hpp" 00027 #include "util/type/util_type.hpp" 00028 #include "util/error/Log.hpp" 00029 00030 namespace se_core { 00031 class _SeCoreExport Parameter { 00032 public: 00033 inline void* data(short size) { 00034 Assert(size < MAX_DATA_SIZE); 00035 return data_; 00036 } 00037 00038 inline unsigned short channel() const { return channel_; } 00039 void setChannel(unsigned short ch) { channel_ = ch; } 00040 inline unsigned short actionStage() const { return actionStage_; } 00041 void incrActionStage() { ++actionStage_; } 00042 void resetActionStage() { actionStage_ = 0; } 00043 00044 private: 00045 static const short MAX_DATA_SIZE = (sizeof(coor_t) * 4 + sizeof(void*)); 00046 unsigned short actionStage_, channel_; 00047 unsigned char data_[MAX_DATA_SIZE]; 00048 }; 00049 00050 00051 class _SeCoreExport ActionAndParameter { 00052 public: 00053 ActionAndParameter() 00054 : action_(0) { 00055 } 00056 00057 ~ActionAndParameter() { 00058 } 00059 00060 00061 inline void set(const ActionAndParameter& orig) { 00062 *this = orig; 00063 } 00064 00065 inline bool hasAction() const { 00066 return action_ != 0; 00067 } 00068 00069 inline const Action& setAction(const Action& a) { 00070 action_ = &a; 00071 parameter_.resetActionStage(); 00072 setDisrupted(false); 00073 return *action_; 00074 } 00075 00076 00077 void setDisrupted(bool state) { 00078 isDisrupted_ = state; 00079 } 00080 00081 bool isDisrupted() { 00082 return isDisrupted_; 00083 } 00084 00085 inline void resetAction() { 00086 action_ = 0; 00087 } 00088 00089 00090 inline const Action* action() const { 00091 return action_; 00092 } 00093 00094 00095 inline void copyParameter(const Parameter& original) { 00096 Parameter& p = parameter(); 00097 p = original; 00098 } 00099 00100 inline const Parameter& parameter() const { 00101 return parameter_; 00102 } 00103 00104 00105 inline Parameter& parameter() { 00106 return parameter_; 00107 } 00108 00109 inline void* parameter(short size) { 00110 return parameter().data(size); 00111 } 00112 00113 private: 00114 const Action* action_; 00115 Parameter parameter_; 00116 bool isDisrupted_; 00117 }; 00118 00119 } 00120 00121 #endif
Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:10 2007 by Doxygen version 1.3.9.1.