Veda/PackDynamicType.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_PackDynamicType_H
00006 #define COM_M4NKIND_PackDynamicType_H
00007 
00008 #include "PackStruct.h"
00009 #include "PackULong_Enums.h"
00010 class BaseObject;
00011 /*!
00012     \class  PackDynamicType
00013     \ingroup    BaseSerializableClass
00014     \brief   PackDynamicType serializes and manages an enumeration number (like PackULong_Enums) that
00015                 define the shape of what is serialized with. the different shapes have to be registered
00016                 through RegisterShapeConstructors() at construction, so it has to be extended to be active. 
00017                 See exemple in VedaLibImage / PackDynamicFloat.
00018 */
00019 class PackDynamicType : public PackStruct
00020 {
00021 /*==================================================================
00022                                 PUBLIC
00023 ==================================================================*/
00024 public:
00025 
00026     /*!
00027         \brief  Constructor. 
00028     */
00029     PackDynamicType(void);
00030 
00031 #ifdef _ENGINE_EDITABLE_
00032     /*!
00033         \brief  Destructor. 
00034     */
00035     virtual ~PackDynamicType(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                 Note: it is a PackStruct, but is not declared as a packstruct, as it has only one of the members valid.
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 "PackDynamicType"; };
00069 #endif
00070 #ifdef _ENGINE_EDITABLE_
00071     /*!
00072         \brief  convert the value of this object to an explicit string. The object manages the string privately,
00073             so just read it or copy it. the string would be destroyed with the objects, and changed when using Set() methods.
00074              Note: this is not virtual, but each class can manage m_pValueString or not.
00075         \return the value as a const string. 
00076     */
00077     virtual const char  *ValueToString();
00078 #endif
00079     
00080 #ifdef _ENGINE_EDITABLE_
00081     /*!
00082         \brief  Change the shape of this dynamic Type.
00083         \param  _shapeEnum an enum value, its meaning vary with registered types.
00084     */
00085     void Set(unsigned int _shapeEnum );
00086 #endif
00087 #ifdef _ENGINE_EDITABLE_
00088     /*!
00089         \brief  get the current effective type.
00090         \return a BaseType. type is one of the registered shapes, or 0L.
00091     */
00092     inline BaseType *Get(){ return m_pSelectedType; };
00093 #endif
00094 
00095     /*!
00096         \brief  get the current effective type.
00097         \return a BaseType. type is one of the registered shapes, or 0L.
00098     */
00099     inline unsigned int GetSelectedIndex(){ return mSer_TypeEnum.Get(); };
00100 
00101 /*==================================================================
00102                                 PROTECTED
00103 ==================================================================*/
00104 protected:
00105     //! the enum that choose the active shape: 0 always means: "nothing".
00106     PackULong_Enums     mSer_TypeEnum;
00107 
00108     //! the object that currently really is the object. can be 0L:
00109     BaseType    *m_pSelectedType;
00110 
00111 };
00112 
00113 // end of file:
00114 #endif

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