Veda/NamedObject.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_NamedObject_H
00006 #define COM_M4NKIND_NamedObject_H
00007 
00008 #include "PackStruct.h"
00009 // Serializable base types needed:
00010 #include "PackString.h"
00011 
00012 
00013 /*!
00014     \class  NamedObject
00015 
00016     \brief  Private use. Base type for all Chunk Named class: It is derived from PackStruct.
00017             Basically, all chunk starting with a jump-length, then a name, will use this.
00018             It is then derivated into ClassNode and BaseObject, which are different in their use.
00019 
00020 */
00021 
00022 class NamedObject : public PackStruct
00023 {
00024 /*==================================================================
00025                                 PUBLIC
00026 ==================================================================*/
00027 public:
00028     /*!
00029         \brief  Constructor. 
00030     */
00031     NamedObject(void);
00032 #ifdef _ENGINE_EDITABLE_
00033     /*!
00034         \brief  Destructor. 
00035     */
00036     virtual ~NamedObject(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.
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 
00061     /*!
00062         \brief  the chunk length once serialized. should be valid just after in or out serialisation, but not if the object was modified. use GetSerializedDescriptionSize() instead.
00063         \return the chunk length
00064     */
00065     inline unsigned int GetChunkLength(){ return(mSerUlong_ChunkLength.Get() );  };
00066 
00067     /*!
00068         \brief  Return the name of the object as a character string.
00069         \return the name.
00070     */
00071     inline const char *  GetName(void) const{ return( mSerStr_ObjectName.Get() ); };
00072 
00073 #ifdef _ENGINE_EDITABLE_
00074     /*!
00075         \brief  set the name of the object as a character string. This is copied of course.
00076         \param _pname teh new name
00077     */
00078     void  SetName( const char * _pname );
00079 #endif
00080 
00081 /*==================================================================
00082                                 PROTECTED
00083 ==================================================================*/
00084 protected:
00085     //! all named objects, ClassNode and BaseObjects, has the ability to jump over the chunk without reading it:
00086     PackULong       mSerUlong_ChunkLength;
00087     /*! Serializable member that stands for the name of the object, and can be used to reference it
00088         in the context database. A name should not (and can't) be used twice in the whole context.
00089     */
00090     PackString      mSerStr_ObjectName;
00091 
00092     //! an object can belong (or not) to a BaseContext, as an object.
00093     BaseContext             *m_pBaseContext;
00094     
00095 };
00096 
00097 #endif

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