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 "celtool/celtoolextern.h" 00031 00032 #include "physicallayer/persist.h" 00033 #include "physicallayer/propclas.h" 00034 00035 struct iCelPlLayer; 00036 00043 class CEL_CELTOOL_EXPORT celStandardLocalEntitySet : 00044 public scfImplementation1<celStandardLocalEntitySet, 00045 iCelLocalEntitySet> 00046 { 00047 private: 00048 iCelPlLayer* pl; 00049 00050 csArray<iCelEntity*> local_entities; 00051 csSet<csPtrKey<iCelEntity> > local_entities_set; 00052 00053 public: 00054 celStandardLocalEntitySet (iCelPlLayer* pl); 00055 virtual ~celStandardLocalEntitySet (); 00056 00057 virtual size_t GetEntityCount () const 00058 { 00059 return local_entities.GetSize (); 00060 } 00061 virtual iCelEntity* GetEntity (size_t idx) const 00062 { 00063 return local_entities[idx]; 00064 } 00065 virtual void AddEntity (iCelEntity* entity) 00066 { 00067 local_entities.Push (entity); 00068 local_entities_set.Add (entity); 00069 } 00070 virtual bool IsLocal (iCelEntity* entity) 00071 { 00072 return local_entities_set.In (entity); 00073 } 00074 virtual bool IsLocal (iCelPropertyClass* pc) 00075 { 00076 return local_entities_set.In (pc->GetEntity ()); 00077 } 00078 virtual csPtr<iCelDataBuffer> SaveExternalEntity (iCelEntity* entity); 00079 virtual iCelEntity* FindExternalEntity (iCelDataBuffer* databuf); 00080 virtual csPtr<iCelDataBuffer> SaveExternalPC (iCelPropertyClass* pc); 00081 virtual iCelPropertyClass* FindExternalPC (iCelDataBuffer* databuf); 00082 }; 00083 00087 class CEL_CELTOOL_EXPORT celStandardPersistentDataList : 00088 public scfImplementation1<celStandardPersistentDataList, 00089 iCelPersistentDataList> 00090 { 00091 private: 00092 class celPersistentDataEntry 00093 { 00094 public: 00095 csRef<iCelDataBuffer> databuf; 00096 csString pc_name; 00097 csString pc_tag; 00098 }; 00099 csArray<celPersistentDataEntry*> data_list; 00100 00101 public: 00102 celStandardPersistentDataList (); 00103 virtual ~celStandardPersistentDataList (); 00104 00105 virtual size_t GetCount () const 00106 { return data_list.GetSize (); } 00107 00108 virtual bool GetPersistentData (size_t idx, csRef<iCelDataBuffer>& databuf, 00109 csString& pc_name, csString& pc_tag) const; 00110 00111 virtual void AddPersistentData (csRef<iCelDataBuffer>& databuf, 00112 csString& pc_name, csString& pc_tag); 00113 }; 00114 00115 #endif // __CEL_CELTOOL_PERSISTHELPER__ 00116
Generated for CEL: Crystal Entity Layer 1.4.1 by doxygen 1.7.1