Veda/PackLong.h

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

      /\/\        4         N         k         !         N         D
                      _______  _ __ ___  _____            ___ _ _  ____
     ___________  __//___   /________  |/    / ___________\_______/    \
    /   _   _   \/   _     /    _   /      _/_/____/    _       __     /
   /    /   /       /     /    /    \      \/     /    /    \   \     /
  \\___/___/___/    ¯    _____/_____/       ______\___/_____/\________\\
               \________/_ ___ __ l____\      /elD!  
                 http://www.m4nkind.com \____/