physicallayer/propclas.h
00001 /* 00002 Crystal Space Entity Layer 00003 Copyright (C) 2001 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., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CEL_PL_PROPCLASS__ 00021 #define __CEL_PL_PROPCLASS__ 00022 00023 #include "cstypes.h" 00024 #include "csutil/scf.h" 00025 #include "csutil/strset.h" 00026 #include "csutil/ref.h" 00027 #include "physicallayer/datatype.h" 00028 #include "physicallayer/entity.h" 00029 #include "physicallayer/persist.h" 00030 00031 struct iCelPropertyClassList; 00032 00039 #define CEL_QUERY_PROPCLASS(PcList,Interface) \ 00040 (celQueryPropertyClass<Interface> (PcList)) 00041 00046 #define CEL_QUERY_PROPCLASS_TAG(PcList,Interface,Tag) \ 00047 (celQueryPropertyClassTag<Interface> (PcList,Tag)) 00048 00055 #define CEL_QUERY_PROPCLASS_ENT(Ent,Interface) \ 00056 (celQueryPropertyClassEntity<Interface> (Ent)) 00057 00062 #define CEL_QUERY_PROPCLASS_TAG_ENT(Ent,Interface,Tag) \ 00063 CEL_QUERY_PROPCLASS_TAG((Ent)->GetPropertyClassList(),Interface,Tag) 00064 00068 #define CEL_REMOVE_PROPCLASS(PcList,Interface) \ 00069 ((PcList)->RemoveByInterface (scfInterfaceTraits<Interface>::GetID(), \ 00070 scfInterfaceTraits<Interface>::GetVersion())) 00071 00076 #define CEL_REMOVE_PROPCLASS_TAG(PcList,Interface,Tag) \ 00077 ((PcList)->RemoveByInterfaceAndTag ( \ 00078 scfInterfaceTraits<Interface>::GetID(), \ 00079 scfInterfaceTraits<Interface>::GetVersion(), Tag)) 00080 00084 #define CEL_REMOVE_PROPCLASS_ENT(Ent, Interface) \ 00085 CEL_REMOVE_PROPCLASS((Ent)->GetPropertyClassList(),Interface) 00086 00091 #define CEL_REMOVE_PROPCLASS_TAG_ENT(Ent,Interface,Tag) \ 00092 CEL_REMOVE_PROPCLASS_TAG((Ent)->GetPropertyClassList(),Interface,Tag) 00093 00094 class csVector3; 00095 class csColor; 00096 struct iCelEntity; 00097 struct iCelDataBuffer; 00098 struct iCelPropertyChangeCallback; 00099 struct iCelParameterBlock; 00100 00105 struct iCelPropertyClass : public virtual iBase 00106 { 00107 SCF_INTERFACE (iCelPropertyClass, 0, 0, 8); 00108 00112 virtual void SetName (const char* name) = 0; 00113 00117 virtual const char* GetName () const = 0; 00118 00122 virtual iObject *QueryObject () = 0; 00123 00130 virtual void SetTag (const char* tagname) = 0; 00131 00136 virtual const char* GetTag () const = 0; 00137 00141 virtual iCelEntity* GetEntity () = 0; 00142 00146 virtual void SetEntity (iCelEntity* entity) = 0; 00147 00156 virtual csPtr<iCelDataBuffer> SaveFirstPass () = 0; 00157 00163 virtual bool LoadFirstPass (iCelDataBuffer* databuf) = 0; 00164 00168 virtual csPtr<iCelDataBuffer> Save () = 0; 00169 00173 virtual bool Load (iCelDataBuffer* databuf) = 0; 00174 00182 virtual bool AddPropertyChangeCallback (iCelPropertyChangeCallback* cb) = 0; 00183 00190 virtual bool RemovePropertyChangeCallback ( 00191 iCelPropertyChangeCallback* cb) = 0; 00192 00205 virtual bool SetProperty (csStringID propertyID, long value) = 0; 00206 00210 virtual bool SetProperty (csStringID propertyID, float value) = 0; 00211 00215 virtual bool SetProperty (csStringID propertyID, bool value) = 0; 00216 00220 virtual bool SetProperty (csStringID propertyID, const char* value) = 0; 00221 00225 virtual bool SetProperty (csStringID propertyID, const csVector2& value) = 0; 00226 00230 virtual bool SetProperty (csStringID propertyID, const csVector3& value) = 0; 00231 00235 virtual bool SetProperty (csStringID propertyID, const csColor& value) = 0; 00236 00240 virtual bool SetProperty (csStringID propertyID, 00241 iCelPropertyClass* value) = 0; 00242 00246 virtual bool SetProperty (csStringID propertyID, iCelEntity* entity) = 0; 00247 00251 virtual bool SetProperty (csStringID propertyID, iBase* ibase) = 0; 00252 00267 virtual celDataType GetPropertyOrActionType ( 00268 csStringID propertyID) = 0; 00269 00273 virtual bool IsPropertyReadOnly (csStringID propertyID) = 0; 00274 00278 virtual long GetPropertyLongByID (csStringID propertyID) = 0; 00279 00283 virtual float GetPropertyFloatByID (csStringID propertyID) = 0; 00284 00288 virtual bool GetPropertyBoolByID (csStringID propertyID) = 0; 00289 00293 virtual const char* GetPropertyStringByID (csStringID propertyID) = 0; 00294 00298 virtual bool GetPropertyVectorByID (csStringID propertyID, csVector2& v) = 0; 00299 00303 virtual bool GetPropertyVectorByID (csStringID propertyID, csVector3& v) = 0; 00304 00308 virtual bool GetPropertyColorByID (csStringID propertyID, csColor& v) = 0; 00309 00313 virtual iCelPropertyClass* GetPropertyPClassByID (csStringID propertyID) = 0; 00314 00318 virtual iCelEntity* GetPropertyEntityByID (csStringID propertyID) = 0; 00319 00323 virtual iBase* GetPropertyIBaseByID (csStringID propertyID) = 0; 00324 00333 virtual bool PerformAction (csStringID actionID, 00334 iCelParameterBlock* params, celData& ret) = 0; 00335 00339 virtual size_t GetPropertyAndActionCount () = 0; 00340 00344 virtual csStringID GetPropertyOrActionID (size_t i) = 0; 00345 00349 virtual const char* GetPropertyOrActionDescription (csStringID) = 0; 00350 00358 virtual void PropertyClassesHaveChanged () = 0; 00359 00364 virtual csPtr<iCelDataBuffer> GetPersistentData ( 00365 celPersistenceType persistence_type) = 0; 00366 00378 virtual celPersistenceResult SetPersistentData (csTicks data_time, 00379 iCelDataBuffer* data, celPersistenceType persistence_type) = 0; 00380 }; 00381 00382 00386 struct iCelPropertyClassList : public virtual iBase 00387 { 00388 SCF_INTERFACE (iCelPropertyClassList, 0, 0, 2); 00389 00393 virtual size_t GetCount () const = 0; 00394 00398 virtual iCelPropertyClass* Get (size_t n) const = 0; 00399 00403 virtual size_t Add (iCelPropertyClass* obj) = 0; 00404 00408 virtual bool Remove (iCelPropertyClass* obj) = 0; 00409 00413 virtual bool Remove (size_t n) = 0; 00414 00418 virtual bool RemoveByInterface (scfInterfaceID scf_id, int iVersion) = 0; 00419 00424 virtual bool RemoveByInterfaceAndTag (scfInterfaceID scf_id, 00425 int iVersion, const char* tag) = 0; 00426 00430 virtual void RemoveAll () = 0; 00431 00435 virtual size_t Find (iCelPropertyClass* obj) const = 0; 00436 00443 virtual iCelPropertyClass* FindByName (const char *name) const = 0; 00444 00449 virtual iCelPropertyClass* FindByNameAndTag (const char *name, 00450 const char* tag) const = 0; 00451 00459 virtual iBase* FindByInterface ( 00460 scfInterfaceID id, int version) const = 0; 00461 00466 virtual iBase* FindByInterfaceAndTag ( 00467 scfInterfaceID id, int version, const char* tag) const = 0; 00468 }; 00469 00474 template<class Interface> 00475 inline csPtr<Interface> celQueryPropertyClassTag ( 00476 iCelPropertyClassList* plist, const char* tag) 00477 { 00478 iBase* base = plist->FindByInterfaceAndTag ( 00479 scfInterfaceTraits<Interface>::GetID (), 00480 scfInterfaceTraits<Interface>::GetVersion (), 00481 tag); 00482 00483 if (base == 0) return csPtr<Interface> (0); 00484 00485 Interface* x = (Interface*)base->QueryInterface ( 00486 scfInterfaceTraits<Interface>::GetID (), 00487 scfInterfaceTraits<Interface>::GetVersion ()); 00488 00489 base->DecRef (); // Release our base interface. 00490 return csPtr<Interface> (x); 00491 } 00492 00499 template<class Interface> 00500 inline csPtr<Interface> celQueryPropertyClass ( 00501 iCelPropertyClassList* plist) 00502 { 00503 iBase* base = plist->FindByInterface ( 00504 scfInterfaceTraits<Interface>::GetID (), 00505 scfInterfaceTraits<Interface>::GetVersion ()); 00506 00507 if (base == 0) return csPtr<Interface> (0); 00508 00509 Interface* x = (Interface*)base->QueryInterface ( 00510 scfInterfaceTraits<Interface>::GetID (), 00511 scfInterfaceTraits<Interface>::GetVersion ()); 00512 00513 base->DecRef (); // Release our base interface. 00514 return csPtr<Interface> (x); 00515 } 00516 00523 template<class Interface> 00524 inline csPtr<Interface> celQueryPropertyClassEntity ( 00525 iCelEntity* entity) 00526 { 00527 return celQueryPropertyClass<Interface> (entity->GetPropertyClassList ()); 00528 } 00529 00530 #endif // __CEL_PL_PROPCLASS__ 00531
Generated for CEL: Crystal Entity Layer 2.0 by doxygen 1.6.1
