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_PackList_H 00006 #define COM_M4NKIND_PackList_H 00007 00008 #include "PackStruct.h" 00009 00010 /*! 00011 \class PackList 00012 \ingroup BaseSerializableClass 00013 \brief Base type managing a list of any PackSerializable (or inherited) Objects 00014 from the same class. In edition mode, you can grow or shorten the list. 00015 GetFirstCell() give you a first 'PackListCell', then you can scan the list element 00016 with PackListCell::GetNextBrotherCell() and PackListCell::GetManagedObject(). 00017 */ 00018 00019 class PackList : public PackStruct 00020 { 00021 /*================================================================== 00022 PUBLIC 00023 ==================================================================*/ 00024 public: 00025 /*! 00026 \brief Constructor. 00027 \param _func a function that return a new object to manage as an element of the list. 00028 */ 00029 PackList( BaseTypeCreatorCallBackFunction _func); 00030 #ifdef _ENGINE_EDITABLE_ 00031 /*! 00032 \brief Destructor. 00033 */ 00034 virtual ~PackList(void); 00035 #endif 00036 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 #ifdef _ENGINE_EDITABLE_ 00044 /*! 00045 \brief get the size of the whole byte chunk that will be written by Serialize_Out(). 00046 \return byte size of the serialisation to do. 00047 */ 00048 virtual unsigned int GetSerializedDescriptionSize(void); 00049 #endif 00050 #ifdef _ENGINE_EDITABLE_ 00051 /*! 00052 \brief write the Current object definition to a Chunk using private packed types, recursively. 00053 \param _pDescriptionChunkToFill the chunk where to write the objet description chunk. 00054 \return the end of the chunk written, possibly unlocated. Don't use this if you don't need it. 00055 */ 00056 virtual unsigned char * Serialize_Out(unsigned char * _pDescriptionChunkToFill); 00057 #endif 00058 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 "PackList"; }; 00068 #endif 00069 #ifdef _ENGINE_EDITABLE_ 00070 /*! 00071 \brief Add a new element, at the given index, in edition context. 00072 in non-editable, it shouldnt be used, and serialization recreate the elements. 00073 \param _indexWhereToInsert the index where to insert. if -1, at the end. 00074 \param _pObjectToAdd object to manage, or NULL to set it after on the cell. 00075 \return the element created. 00076 */ 00077 virtual Cell * AddElement( int _indexWhereToInsert=-1,BaseType *_pObjectToAdd=0L); 00078 #endif 00079 #ifdef _ENGINE_EDITABLE_ 00080 /*! 00081 \brief delete an element at a given index. It closes and destroys the object. 00082 \param _index index of the object to destroy. 00083 */ 00084 virtual void DeleteElement( unsigned int _index); 00085 #endif 00086 #ifdef _ENGINE_EDITABLE_ 00087 /*! 00088 \brief delete an element at a given index. It closes and destroys the object. 00089 \param _pObWhichCellIsToDestroy ob WhichCellIsToDestroy. 00090 */ 00091 virtual void DeleteElement( BaseType *_pObWhichCellIsToDestroy); 00092 #endif 00093 #ifdef _ENGINE_EDITABLE_ 00094 /*! 00095 \brief Acts like Serialize_In() but keep all previous objects. 00096 So you can load and mix 2 or more context this way. 00097 00098 \param _pDescriptionChunk the binary image of a context. 00099 \param _pendName specify a name to add at the end of each new object. 00100 */ 00101 virtual const unsigned char * MergeSerialize_In( const unsigned char * _pDescriptionChunk,const char *_pendName=0L); 00102 #endif 00103 #ifdef _ENGINE_EDITABLE_ 00104 /*! 00105 \brief Edition tool: Exchange 2 neighbour elements in the list, if there is a next element. 00106 if index is 0, 0 will be 1 and 1 will be 0. 00107 \param _indexOfElementToSwapWithNext any row, from zero to GetNumberOfCell()-2 00108 */ 00109 virtual void SwapElements( unsigned int _indexOfElementToSwapWithNext); 00110 #endif 00111 #ifdef _ENGINE_EDITABLE_ 00112 /*! 00113 \brief Insert a new element after _indexOfElementToClone, 00114 and clone it with the previous element shape. Note this 00115 can exclude some data members, like Object reference. 00116 \param _indexOfElementToClone any row, from zero to GetNumberOfCell()-1 00117 */ 00118 virtual void CloneElement( unsigned int _indexOfElementToClone); 00119 #endif 00120 /*================================================================== 00121 PROTECTED 00122 ==================================================================*/ 00123 protected: 00124 //! thechunk length of the list: 00125 PackULong mSerUlong_ChunkLength; 00126 //! Static Method Pointer to the NewObject function used to create the object that this node manage. 00127 BaseTypeCreatorCallBackFunction m_CreatorFunc; 00128 00129 }; 00130 #endif
/\/\ 4 N k ! N D _______ _ __ ___ _____ ___ _ _ ____ ___________ __//___ /________ |/ / ___________\_______/ \ / _ _ \/ _ / _ / _/_/____/ _ __ / / / / / / / \ \/ / / \ \ / \\___/___/___/ ¯ _____/_____/ ______\___/_____/\________\\ \________/_ ___ __ l____\ /elD! http://www.m4nkind.com \____/