00001 /*************************************************************************** 00002 * The contents of this file are subject to the Mozilla Public * 00003 * License Version 1.1 (the "License"); you may not use this file * 00004 * except in compliance with the License. You may obtain a copy of * 00005 * the License at http://www.mozilla.org/MPL/ * 00006 * * 00007 * Software distributed under the License is distributed on an "AS * 00008 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * 00009 * implied. See the License for the specific language governing * 00010 * rights and limitations under the License. * 00011 * * 00012 * The Original Code is Game Network Framework (GaNeF). * 00013 * * 00014 * The Initial Developers of the Original Code are * 00015 * Lars Langer and Emanuel Greisen * 00016 * Copyright (C) 2005. Lars Langer & Emanuel Greisen * 00017 * All Rights Reserved. * 00018 * * 00019 * Contributor(s): * 00020 * none yet.... * 00021 * * 00022 ***************************************************************************/ 00023 #ifndef CLIENTDATAMAP_H 00024 #define CLIENTDATAMAP_H 00025 00026 #include <map> 00027 #include <vector> 00028 00029 class ClientData; 00030 00031 typedef std::vector<ClientData **> PtrPtrVec; 00032 typedef std::map<unsigned int, PtrPtrVec> PPMap; 00033 00034 struct PointingMapStruct 00035 { 00036 PPMap ppmap; 00037 std::map<ClientData **, unsigned int> ptr2pointee; 00038 bool isEmpty() const 00039 { 00040 return ppmap.size() == 0 && ptr2pointee.size() == 0; 00041 } 00042 }; 00043 typedef std::map<const unsigned int, PPMap > PointeeMap; 00044 typedef std::map<const unsigned int, PointingMapStruct > PointingMap; 00045 00046 /** 00047 * @ingroup Client 00048 * @brief This class is used for handling the data elements of the client. 00049 * It will make sure that elements pointing to objects which haven't been 00050 * initilized will be set to point at the correct element after it has been 00051 * initilized. It will also manage the deletion of objects and ensure that objects 00052 * pointing to deleted objects will recieve a null poiter 00053 * 00054 * @author Lars Langer and Emanuel Greisen 00055 */ 00056 class ClientDataMap 00057 { 00058 public: 00059 /// < id of object missing a pointer, vetor of objects it is missing a pointer to and the pointer > 00060 PointingMap pointing_map; 00061 /// < id of object being missed, a vetor of objects missing this pointer and the pointer to set > 00062 PointeeMap pointee_map; 00063 00064 00065 // Lars - please see report! 00066 00067 public: 00068 ClientDataMap(); 00069 ~ClientDataMap(); 00070 00071 public: 00072 void unregisterData( ClientData * data); 00073 void registerPointer( unsigned int receiver, unsigned int missing, ClientData ** ptrptr ); 00074 bool unregisterPointer(unsigned int receiver, unsigned int new_objid, ClientData **ptrptr); 00075 void printDebug(); 00076 00077 00078 }; 00079 00080 #endif