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_PackULong_H 00006 #define COM_M4NKIND_PackULong_H 00007 00008 #include "BaseType.h" 00009 00010 /*! 00011 \class PackULong 00012 \ingroup BaseSerializableClass 00013 \brief Base type managing "28 bit unsigned long", which serialize a number 00014 between [0,512Mb-1], which can be written on 1, 2,3 or 4 bytes when needed. 00015 It is used for the automated serialization managed by class PackStruct. 00016 It outputs an "unsigned int" you access with Get() 00017 */ 00018 00019 class PackULong : public BaseType 00020 { 00021 /*================================================================== 00022 PUBLIC 00023 ==================================================================*/ 00024 public: 00025 #ifdef _ENGINE_EDITABLE_ 00026 /*! 00027 \brief Constructor. 00028 */ 00029 PackULong(void); 00030 #endif 00031 #ifdef _ENGINE_EDITABLE_ 00032 /*! 00033 \brief Destructor. 00034 */ 00035 virtual ~PackULong(void); 00036 #endif 00037 /*! 00038 \brief Read the object description from a byte chunk. Could crash if chunk not valid. 00039 \param _pDescriptionChunk the objet description chunk. 00040 \return the end of the chunk written, possibly unlocated. Don't use this if you don't need it. 00041 */ 00042 virtual const unsigned char * Serialize_In( const unsigned char * _pDescriptionChunk); 00043 00044 #ifdef _ENGINE_EDITABLE_ 00045 /*! 00046 \brief get the size of the whole byte chunk that will be written by Serialize_Out(). 00047 \return byte size of the serialisation to do.(1,2,3, or4) 00048 */ 00049 virtual unsigned int GetSerializedDescriptionSize(void); 00050 #endif 00051 #ifdef _ENGINE_EDITABLE_ 00052 /*! 00053 \brief write the Current object definition to a Chunk using private packed types, recursively. 00054 \param _pDescriptionChunkToFill the chunk where to write the objet description chunk. 00055 \return the end of the chunk written, possibly unlocated. Don't use this if you don't need it. 00056 */ 00057 virtual unsigned char * Serialize_Out(unsigned char * _pDescriptionChunkToFill); 00058 #endif 00059 #ifdef _ENGINE_EDITABLE_ 00060 /*! 00061 \brief Each BaseType's inherited classes must explicit an ID for their 00062 class, or let use one of the super class at least through this virtual method. 00063 This is needed by GUIs to detect the types of each sub-members, and shape 00064 an interface for each Object according to their member list. 00065 \return a const character string, that must be unique and unchanged for all serializable base type. 00066 */ 00067 virtual const char *GetClassID() const { return("PackULong"); }; 00068 #endif 00069 #ifdef _ENGINE_EDITABLE_ 00070 /*! 00071 \brief convert the value of this object to an explicit string. The object manages the string privately, 00072 so just read it or copy it. the string would be destroyed with the objects, and changed when using Set() methods. 00073 Note: this is not virtual, but each class can manage m_pValueString or not. 00074 \return the value as a const string. 00075 */ 00076 virtual const char *ValueToString(); 00077 #endif 00078 #ifdef _ENGINE_EDITABLE_ 00079 /*! 00080 \brief change the value: 00081 \param _value 28b unsigned int value. 00082 */ 00083 virtual void Set(unsigned int _value); 00084 #endif 00085 /*! 00086 \brief Get the value 00087 \return the 28b unsigned int value. 00088 */ 00089 inline unsigned int Get() const { return m_value ; }; 00090 /*! 00091 \brief change the value: 00092 \param _value 28b unsigned int value. 00093 */ 00094 inline void operator +=(unsigned int _value){ m_value += _value; }; 00095 00096 /*================================================================== 00097 PROTECTED 00098 ==================================================================*/ 00099 protected: 00100 /*! the value of this class: 00101 Note that it will be trunked to 256Mb-1 maximum at serialization! 00102 */ 00103 unsigned int m_value; 00104 }; 00105 00106 /*! 00107 \def REGISTER_MEMBER_PACKULONG 00108 00109 \brief This macro is used to register a serializable member in a class constructor. 00110 For editable mode, it uses _MemberName to explicit the use of the member, in order 00111 to display it in a GUI for example. 00112 00113 */ 00114 #ifdef _ENGINE_EDITABLE_ 00115 #define REGISTER_MEMBER_PACKULONG(_object,_MemberName,_DefaultVal) \ 00116 RegisterSerializableMember(_object);\ 00117 _object.SetMemberName( _MemberName );\ 00118 _object.Set(_DefaultVal); 00119 #else 00120 #define REGISTER_MEMBER_PACKULONG(_object,_MemberName,_DefaultVal) \ 00121 RegisterSerializableMember(_object); 00122 #endif 00123 00124 // end of file: 00125 #endif
/\/\ 4 N k ! N D _______ _ __ ___ _____ ___ _ _ ____ ___________ __//___ /________ |/ / ___________\_______/ \ / _ _ \/ _ / _ / _/_/____/ _ __ / / / / / / / \ \/ / / \ \ / \\___/___/___/ ¯ _____/_____/ ______\___/_____/\________\\ \________/_ ___ __ l____\ /elD! http://www.m4nkind.com \____/