00001 /*! \file 00002 \author victorien ferry & www.m4nkind.com 00003 \brief This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING. 00004 */ 00005 #ifndef COM_M4NKIND_PackFloatByte_Limits_H 00006 #define COM_M4NKIND_PackFloatByte_Limits_H 00007 00008 #include "PackFloat.h" 00009 00010 /*! 00011 \class PackFloatByte_Limits 00012 \ingroup BaseSerializableClass 00013 \brief manage a float value, but serialize it in 1 byte, where the 256 value domain 00014 is scaled between 2 float given at inition. default ends are:[ 0.0f , 1.0f [ 00015 00016 */ 00017 00018 class PackFloatByte_Limits : public PackFloat 00019 { 00020 /*================================================================== 00021 PUBLIC 00022 ==================================================================*/ 00023 public: 00024 00025 /*! 00026 \brief Constructor. 00027 */ 00028 PackFloatByte_Limits(void); 00029 /*! 00030 \brief Constructor To initialize PackFloat as a multi dimentional vector. 00031 \param _DimensionEnum on of the 3 VectorDimension enum. 00032 */ 00033 PackFloatByte_Limits( VectorDimension _DimensionEnum ); 00034 00035 #ifdef _ENGINE_EDITABLE_ 00036 /*! 00037 \brief Destructor. 00038 */ 00039 virtual ~PackFloatByte_Limits(void); 00040 #endif 00041 /*! 00042 \brief Read the object description from a byte chunk. Could crash if chunk not valid. 00043 \param _pDescriptionChunk the objet description chunk. 00044 \return the end of the chunk written, possibly unlocated. Don't use this if you don't need it. 00045 */ 00046 virtual const unsigned char * Serialize_In( const unsigned char * _pDescriptionChunk); 00047 00048 #ifdef _ENGINE_EDITABLE_ 00049 /*! 00050 \brief get the size of the whole byte chunk that will be written by Serialize_Out(). 00051 \return byte size of the serialisation to do.(1,2,3, or4) 00052 */ 00053 virtual unsigned int GetSerializedDescriptionSize(void); 00054 #endif 00055 #ifdef _ENGINE_EDITABLE_ 00056 /*! 00057 \brief write the Current object definition to a Chunk using private packed types, recursively. 00058 \param _pDescriptionChunkToFill the chunk where to write the objet description chunk. 00059 \return the end of the chunk written, possibly unlocated. Don't use this if you don't need it. 00060 */ 00061 virtual unsigned char * Serialize_Out(unsigned char * _pDescriptionChunkToFill); 00062 #endif 00063 #ifdef _ENGINE_EDITABLE_ 00064 /*! 00065 \brief Each BaseType's inherited classes must explicit an ID for their 00066 class, or let use one of the super class at least through this virtual method. 00067 This is needed by GUIs to detect the types of each sub-members, and shape 00068 an interface for each Object according to their member list. 00069 \return a const character string, that must be unique and unchanged for all serializable base type. 00070 */ 00071 virtual const char *GetClassID() const { return "PackFloat::PackFloatByte_Limits"; }; 00072 #endif 00073 #ifdef _ENGINE_EDITABLE_ 00074 /*! 00075 \brief change the value: 00076 \param 00077 */ 00078 virtual void Set(float _value); 00079 #endif 00080 #ifdef _ENGINE_EDITABLE_ 00081 /*! 00082 \brief change the value of a given dimension: 00083 \param _dimensionIndex 0 for X, 1 for Y, 2 for Z 00084 \param _value value 00085 */ 00086 virtual void Set(unsigned int _dimensionIndex,float _value); 00087 #endif 00088 /*! 00089 \brief Initialize the variation domain with 2 floats, then the 256 possible value will be defined inside. 00090 \param _min minimum 00091 \param _max maximum. 00092 */ 00093 void SetMinMax(float _min,float _max); 00094 00095 /*! 00096 \brief get the minimum 00097 */ 00098 inline float GetMin(){return(m_MinValue);}; 00099 00100 /*! 00101 \brief set the maximum values possible for this type. 00102 */ 00103 inline float GetMax(){return(m_MinValue+m_DomainLength);}; 00104 00105 /*================================================================== 00106 PROTECTED 00107 ==================================================================*/ 00108 protected: 00109 //! minimum value of the variation domain: (this is inited, not serialized) 00110 float m_MinValue; 00111 //! max-Min value of the variation domain: (this is inited, not serialized) 00112 float m_DomainLength; 00113 00114 }; 00115 00116 /*! 00117 \def REGISTER_MEMBER_PACKFLOATBYTE_LIMITS 00118 00119 \brief This macro is used to register a serializable member in a class constructor. 00120 For editable mode, it uses _MemberName to explicit the use of the member, in order 00121 to display it in a GUI for example. 00122 00123 */ 00124 #ifdef _ENGINE_EDITABLE_ 00125 #define REGISTER_MEMBER_PACKFLOATBYTE_LIMITS(_object,_MemberName,_DefaultVal,_min,_max) \ 00126 RegisterSerializableMember(_object);\ 00127 _object.SetMemberName( _MemberName );\ 00128 _object.SetMinMax( _min , _max );\ 00129 _object.Set(_DefaultVal); \ 00130 _object.Set(1,_DefaultVal); \ 00131 _object.Set(2,_DefaultVal); 00132 #define REGISTER_MEMBER_PACKFLOATBYTE_0_1(_object,_MemberName,_DefaultVal) \ 00133 RegisterSerializableMember(_object);\ 00134 _object.SetMemberName( _MemberName );\ 00135 _object.Set(_DefaultVal); \ 00136 _object.Set(1,_DefaultVal); \ 00137 _object.Set(2,_DefaultVal); 00138 #else 00139 00140 #define REGISTER_MEMBER_PACKFLOATBYTE_LIMITS(_object,_MemberName,_DefaultVal,_min,_max) \ 00141 RegisterSerializableMember(_object);\ 00142 _object.SetMinMax( _min , _max ); 00143 #define REGISTER_MEMBER_PACKFLOATBYTE_0_1(_object,_MemberName,_DefaultVal) \ 00144 RegisterSerializableMember(_object); 00145 // end if engine not editable: 00146 #endif 00147 00148 // end of .h: 00149 #endif
/\/\ 4 N k ! N D _______ _ __ ___ _____ ___ _ _ ____ ___________ __//___ /________ |/ / ___________\_______/ \ / _ _ \/ _ / _ / _/_/____/ _ __ / / / / / / / \ \/ / / \ \ / \\___/___/___/ ¯ _____/_____/ ______\___/_____/\________\\ \________/_ ___ __ l____\ /elD! http://www.m4nkind.com \____/