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 scfImplementation1< 00042 celStandardLocalEntitySet, iCelLocalEntitySet> 00043 { 00044 private: 00045 iCelPlLayer* pl; 00046 00047 csArray<iCelEntity*> local_entities; 00048 csSet<csPtrKey<iCelEntity> > local_entities_set; 00049 00050 public: 00051 celStandardLocalEntitySet (iCelPlLayer* pl); 00052 virtual ~celStandardLocalEntitySet (); 00053 00054 virtual size_t GetEntityCount () const 00055 { 00056 return local_entities.GetSize (); 00057 } 00058 virtual iCelEntity* GetEntity (size_t idx) const 00059 { 00060 return local_entities[idx]; 00061 } 00062 virtual void AddEntity (iCelEntity* entity) 00063 { 00064 local_entities.Push (entity); 00065 local_entities_set.Add (entity); 00066 } 00067 virtual bool IsLocal (iCelEntity* entity) 00068 { 00069 return local_entities_set.In (entity); 00070 } 00071 virtual bool IsLocal (iCelPropertyClass* pc) 00072 { 00073 return local_entities_set.In (pc->GetEntity ()); 00074 } 00075 virtual csPtr<iCelDataBuffer> SaveExternalEntity (iCelEntity* entity); 00076 virtual iCelEntity* FindExternalEntity (iCelDataBuffer* databuf); 00077 virtual csPtr<iCelDataBuffer> SaveExternalPC (iCelPropertyClass* pc); 00078 virtual iCelPropertyClass* FindExternalPC (iCelDataBuffer* databuf); 00079 }; 00080 00084 class celStandardPersistentDataList : public scfImplementation1< 00085 celStandardPersistentDataList, 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 virtual size_t GetCount () const 00102 { return data_list.GetSize (); } 00103 00104 virtual bool GetPersistentData (size_t idx, csRef<iCelDataBuffer>& databuf, 00105 csString& pc_name, csString& pc_tag) const; 00106 00107 virtual void AddPersistentData (csRef<iCelDataBuffer>& databuf, 00108 csString& pc_name, csString& pc_tag); 00109 }; 00110 00111 #endif // __CEL_CELTOOL_PERSISTHELPER__ 00112
Generated for CEL: Crystal Entity Layer 1.2 by doxygen 1.4.7
