celtool/persisthelper.h
00001 /* 00002 Crystal Space Entity Layer 00003 Copyright (C) 2005 by Jorrit Tyberghein 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00018 MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef __CEL_CELTOOL_PERSISTHELPER__ 00022 #define __CEL_CELTOOL_PERSISTHELPER__ 00023 00024 #include "cstypes.h" 00025 #include "csutil/scf.h" 00026 #include "csutil/util.h" 00027 #include "csutil/array.h" 00028 #include "csutil/set.h" 00029 00030 #include "physicallayer/persist.h" 00031 #include "physicallayer/propclas.h" 00032 00033 struct iCelPlLayer; 00034 00041 class celStandardLocalEntitySet : public iCelLocalEntitySet 00042 { 00043 private: 00044 iCelPlLayer* pl; 00045 00046 csArray<iCelEntity*> local_entities; 00047 csSet<csPtrKey<iCelEntity> > local_entities_set; 00048 00049 public: 00050 celStandardLocalEntitySet (iCelPlLayer* pl); 00051 virtual ~celStandardLocalEntitySet (); 00052 00053 SCF_DECLARE_IBASE; 00054 00055 virtual size_t GetEntityCount () const 00056 { 00057 return local_entities.Length (); 00058 } 00059 virtual iCelEntity* GetEntity (size_t idx) const 00060 { 00061 return local_entities[idx]; 00062 } 00063 virtual void AddEntity (iCelEntity* entity) 00064 { 00065 local_entities.Push (entity); 00066 local_entities_set.Add (entity); 00067 } 00068 virtual bool IsLocal (iCelEntity* entity) 00069 { 00070 return local_entities_set.In (entity); 00071 } 00072 virtual bool IsLocal (iCelPropertyClass* pc) 00073 { 00074 return local_entities_set.In (pc->GetEntity ()); 00075 } 00076 virtual csPtr<iCelDataBuffer> SaveExternalEntity (iCelEntity* entity); 00077 virtual iCelEntity* FindExternalEntity (iCelDataBuffer* databuf); 00078 virtual csPtr<iCelDataBuffer> SaveExternalPC (iCelPropertyClass* pc); 00079 virtual iCelPropertyClass* FindExternalPC (iCelDataBuffer* databuf); 00080 }; 00081 00085 class celStandardPersistentDataList : public iCelPersistentDataList 00086 { 00087 private: 00088 class celPersistentDataEntry 00089 { 00090 public: 00091 csRef<iCelDataBuffer> databuf; 00092 csString pc_name; 00093 csString pc_tag; 00094 }; 00095 csArray<celPersistentDataEntry*> data_list; 00096 00097 public: 00098 celStandardPersistentDataList (); 00099 virtual ~celStandardPersistentDataList (); 00100 00101 SCF_DECLARE_IBASE; 00102 00103 virtual size_t GetCount () const 00104 { return data_list.Length (); } 00105 00106 virtual bool GetPersistentData (size_t idx, csRef<iCelDataBuffer>& databuf, 00107 csString& pc_name, csString& pc_tag) const; 00108 00109 virtual void AddPersistentData (csRef<iCelDataBuffer>& databuf, 00110 csString& pc_name, csString& pc_tag); 00111 }; 00112 00113 #endif // __CEL_CELTOOL_PERSISTHELPER__ 00114
Generated for CEL: Crystal Entity Layer by doxygen 1.4.7