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 00125 virtual void SetTag (const char* tagname) = 0; 00126 00131 virtual const char* GetTag () const = 0; 00132 00136 virtual iCelEntity* GetEntity () = 0; 00137 00141 virtual void SetEntity (iCelEntity* entity) = 0; 00142 00151 virtual csPtr<iCelDataBuffer> SaveFirstPass () = 0; 00152 00158 virtual bool LoadFirstPass (iCelDataBuffer* databuf) = 0; 00159 00163 virtual csPtr<iCelDataBuffer> Save () = 0; 00164 00168 virtual bool Load (iCelDataBuffer* databuf) = 0; 00169 00177 virtual bool AddPropertyChangeCallback (iCelPropertyChangeCallback* cb) = 0; 00178 00185 virtual bool RemovePropertyChangeCallback ( 00186 iCelPropertyChangeCallback* cb) = 0; 00187 00201 virtual bool SetProperty (csStringID propertyID, long value) = 0; 00202 00206 virtual bool SetProperty (csStringID propertyID, float value) = 0; 00207 00211 virtual bool SetProperty (csStringID propertyID, bool value) = 0; 00212 00216 virtual bool SetProperty (csStringID propertyID, const char* value) = 0; 00217 00221 virtual bool SetProperty (csStringID propertyID, const csVector2& value) = 0; 00222 00226 virtual bool SetProperty (csStringID propertyID, const csVector3& value) = 0; 00227 00231 virtual bool SetProperty (csStringID propertyID, const csColor& value) = 0; 00232 00236 virtual bool SetProperty (csStringID propertyID, 00237 iCelPropertyClass* value) = 0; 00238 00242 virtual bool SetProperty (csStringID propertyID, iCelEntity* entity) = 0; 00243 00247 virtual bool SetProperty (csStringID propertyID, iBase* ibase) = 0; 00248 00263 virtual celDataType GetPropertyOrActionType ( 00264 csStringID propertyID) = 0; 00265 00269 virtual bool IsPropertyReadOnly (csStringID propertyID) = 0; 00270 00275 CS_DEPRECATED_METHOD_MSG("Use GetPropertyLongByID() instead.") 00276 virtual long GetPropertyLong (csStringID propertyID) = 0; 00277 00282 CS_DEPRECATED_METHOD_MSG("Use GetPropertyFloatByID() instead.") 00283 virtual float GetPropertyFloat (csStringID propertyID) = 0; 00284 00289 CS_DEPRECATED_METHOD_MSG("Use GetPropertyBoolByID() instead.") 00290 virtual bool GetPropertyBool (csStringID propertyID) = 0; 00291 00296 CS_DEPRECATED_METHOD_MSG("Use GetPropertyStringByID() instead.") 00297 virtual const char* GetPropertyString (csStringID propertyID) = 0; 00298 00303 CS_DEPRECATED_METHOD_MSG("Use GetPropertyVectorByID() instead.") 00304 virtual bool GetPropertyVector (csStringID propertyID, csVector2& v) = 0; 00305 00310 CS_DEPRECATED_METHOD_MSG("Use GetPropertyVectorByID() instead.") 00311 virtual bool GetPropertyVector (csStringID propertyID, csVector3& v) = 0; 00312 00317 CS_DEPRECATED_METHOD_MSG("Use GetPropertyColorByID() instead.") 00318 virtual bool GetPropertyColor (csStringID propertyID, csColor& v) = 0; 00319 00324 CS_DEPRECATED_METHOD_MSG("Use GetPropertyPClassByID() instead.") 00325 virtual iCelPropertyClass* GetPropertyPClass (csStringID propertyID) = 0; 00326 00331 CS_DEPRECATED_METHOD_MSG("Use GetPropertyEntityByID() instead.") 00332 virtual iCelEntity* GetPropertyEntity (csStringID propertyID) = 0; 00333 00338 CS_DEPRECATED_METHOD_MSG("Use GetPropertyIBaseByID() instead.") 00339 virtual iBase* GetPropertyIBase (csStringID propertyID) = 0; 00340 00344 virtual long GetPropertyLongByID (csStringID propertyID) = 0; 00345 00349 virtual float GetPropertyFloatByID (csStringID propertyID) = 0; 00350 00354 virtual bool GetPropertyBoolByID (csStringID propertyID) = 0; 00355 00359 virtual const char* GetPropertyStringByID (csStringID propertyID) = 0; 00360 00364 virtual bool GetPropertyVectorByID (csStringID propertyID, csVector2& v) = 0; 00365 00369 virtual bool GetPropertyVectorByID (csStringID propertyID, csVector3& v) = 0; 00370 00374 virtual bool GetPropertyColorByID (csStringID propertyID, csColor& v) = 0; 00375 00379 virtual iCelPropertyClass* GetPropertyPClassByID (csStringID propertyID) = 0; 00380 00384 virtual iCelEntity* GetPropertyEntityByID (csStringID propertyID) = 0; 00385 00389 virtual iBase* GetPropertyIBaseByID (csStringID propertyID) = 0; 00390 00399 virtual bool PerformAction (csStringID actionID, 00400 iCelParameterBlock* params, celData& ret) = 0; 00401 00405 virtual size_t GetPropertyAndActionCount () = 0; 00406 00410 virtual csStringID GetPropertyOrActionID (size_t i) = 0; 00411 00415 virtual const char* GetPropertyOrActionDescription (csStringID) = 0; 00416 00424 virtual void PropertyClassesHaveChanged () = 0; 00425 00430 virtual csPtr<iCelDataBuffer> GetPersistentData ( 00431 celPersistenceType persistence_type) = 0; 00432 00444 virtual celPersistenceResult SetPersistentData (csTicks data_time, 00445 iCelDataBuffer* data, celPersistenceType persistence_type) = 0; 00446 }; 00447 00448 00452 struct iCelPropertyClassList : public virtual iBase 00453 { 00454 SCF_INTERFACE (iCelPropertyClassList, 0, 0, 2); 00455 00459 virtual size_t GetCount () const = 0; 00460 00464 virtual iCelPropertyClass* Get (size_t n) const = 0; 00465 00469 virtual size_t Add (iCelPropertyClass* obj) = 0; 00470 00474 virtual bool Remove (iCelPropertyClass* obj) = 0; 00475 00479 virtual bool Remove (size_t n) = 0; 00480 00484 virtual bool RemoveByInterface (scfInterfaceID scf_id, int iVersion) = 0; 00485 00490 virtual bool RemoveByInterfaceAndTag (scfInterfaceID scf_id, 00491 int iVersion, const char* tag) = 0; 00492 00496 virtual void RemoveAll () = 0; 00497 00501 virtual size_t Find (iCelPropertyClass* obj) const = 0; 00502 00509 virtual iCelPropertyClass* FindByName (const char *name) const = 0; 00510 00515 virtual iCelPropertyClass* FindByNameAndTag (const char *name, 00516 const char* tag) const = 0; 00517 00525 virtual iBase* FindByInterface ( 00526 scfInterfaceID id, int version) const = 0; 00527 00532 virtual iBase* FindByInterfaceAndTag ( 00533 scfInterfaceID id, int version, const char* tag) const = 0; 00534 }; 00535 00540 template<class Interface> 00541 inline csPtr<Interface> celQueryPropertyClassTag ( 00542 iCelPropertyClassList* plist, const char* tag) 00543 { 00544 iBase* base = plist->FindByInterfaceAndTag ( 00545 scfInterfaceTraits<Interface>::GetID (), 00546 scfInterfaceTraits<Interface>::GetVersion (), 00547 tag); 00548 00549 if (base == 0) return csPtr<Interface> (0); 00550 00551 Interface* x = (Interface*)base->QueryInterface ( 00552 scfInterfaceTraits<Interface>::GetID (), 00553 scfInterfaceTraits<Interface>::GetVersion ()); 00554 00555 base->DecRef (); // Release our base interface. 00556 return csPtr<Interface> (x); 00557 } 00558 00565 template<class Interface> 00566 inline csPtr<Interface> celQueryPropertyClass ( 00567 iCelPropertyClassList* plist) 00568 { 00569 iBase* base = plist->FindByInterface ( 00570 scfInterfaceTraits<Interface>::GetID (), 00571 scfInterfaceTraits<Interface>::GetVersion ()); 00572 00573 if (base == 0) return csPtr<Interface> (0); 00574 00575 Interface* x = (Interface*)base->QueryInterface ( 00576 scfInterfaceTraits<Interface>::GetID (), 00577 scfInterfaceTraits<Interface>::GetVersion ()); 00578 00579 base->DecRef (); // Release our base interface. 00580 return csPtr<Interface> (x); 00581 } 00582 00589 template<class Interface> 00590 inline csPtr<Interface> celQueryPropertyClassEntity ( 00591 iCelEntity* entity) 00592 { 00593 return celQueryPropertyClass<Interface> (entity->GetPropertyClassList ()); 00594 } 00595 00596 #endif // __CEL_PL_PROPCLASS__ 00597
Generated for CEL: Crystal Entity Layer 1.2 by doxygen 1.4.7
