CEL

Public API Reference

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, 7);
00108 
00112   virtual const char* GetName () const = 0;
00113 
00120   virtual void SetTag (const char* tagname) = 0;
00121 
00126   virtual const char* GetTag () const = 0;
00127 
00131   virtual iCelEntity* GetEntity () = 0;
00132 
00136   virtual void SetEntity (iCelEntity* entity) = 0;
00137 
00146   virtual csPtr<iCelDataBuffer> SaveFirstPass () = 0;
00147 
00153   virtual bool LoadFirstPass (iCelDataBuffer* databuf) = 0;
00154 
00158   virtual csPtr<iCelDataBuffer> Save () = 0;
00159 
00163   virtual bool Load (iCelDataBuffer* databuf) = 0;
00164 
00172   virtual bool AddPropertyChangeCallback (iCelPropertyChangeCallback* cb) = 0;
00173 
00180   virtual bool RemovePropertyChangeCallback (
00181         iCelPropertyChangeCallback* cb) = 0;
00182 
00196   virtual bool SetProperty (csStringID propertyID, long value) = 0;
00197 
00201   virtual bool SetProperty (csStringID propertyID, float value) = 0;
00202 
00206   virtual bool SetProperty (csStringID propertyID, bool value) = 0;
00207 
00211   virtual bool SetProperty (csStringID propertyID, const char* value) = 0;
00212 
00216   virtual bool SetProperty (csStringID propertyID, const csVector2& value) = 0;
00217 
00221   virtual bool SetProperty (csStringID propertyID, const csVector3& value) = 0;
00222 
00226   virtual bool SetProperty (csStringID propertyID, const csColor& value) = 0;
00227 
00231   virtual bool SetProperty (csStringID propertyID,
00232         iCelPropertyClass* value) = 0;
00233 
00237   virtual bool SetProperty (csStringID propertyID, iCelEntity* entity) = 0;
00238 
00242   virtual bool SetProperty (csStringID propertyID, iBase* ibase) = 0;
00243 
00260   virtual celDataType GetPropertyOrActionType (
00261         csStringID propertyID) = 0;
00262 
00266   virtual bool IsPropertyReadOnly (csStringID propertyID) = 0;
00267 
00271   virtual long GetPropertyLong (csStringID propertyID) = 0;
00272 
00276   virtual float GetPropertyFloat (csStringID propertyID) = 0;
00277 
00281   virtual bool GetPropertyBool (csStringID propertyID) = 0;
00282 
00286   virtual const char* GetPropertyString (csStringID propertyID) = 0;
00287 
00291   virtual bool GetPropertyVector (csStringID propertyID, csVector2& v) = 0;
00292 
00296   virtual bool GetPropertyVector (csStringID propertyID, csVector3& v) = 0;
00297 
00301   virtual bool GetPropertyColor (csStringID propertyID, csColor& v) = 0;
00302 
00306   virtual iCelPropertyClass* GetPropertyPClass (csStringID propertyID) = 0;
00307 
00311   virtual iCelEntity* GetPropertyEntity (csStringID propertyID) = 0;
00312 
00316   virtual iBase* GetPropertyIBase (csStringID propertyID) = 0;
00317 
00326   virtual bool PerformAction (csStringID actionID,
00327         iCelParameterBlock* params, celData& ret) = 0;
00328 
00332   virtual size_t GetPropertyAndActionCount () const = 0;
00333 
00337   virtual csStringID GetPropertyOrActionID (size_t i) = 0;
00338 
00342   virtual const char* GetPropertyOrActionDescription (csStringID) = 0;
00343 
00351   virtual void PropertyClassesHaveChanged () = 0;
00352 
00357   virtual csPtr<iCelDataBuffer> GetPersistentData (
00358         celPersistenceType persistence_type) = 0;
00359 
00371   virtual celPersistenceResult SetPersistentData (csTicks data_time, 
00372         iCelDataBuffer* data, celPersistenceType persistence_type) = 0;
00373 };
00374 
00375 
00376 SCF_VERSION (iCelPropertyClassList, 0, 0, 2);
00377 
00381 struct iCelPropertyClassList : public iBase
00382 {
00386   virtual size_t GetCount () const = 0;
00387 
00391   virtual iCelPropertyClass* Get (size_t n) const = 0;
00392 
00396   virtual size_t Add (iCelPropertyClass* obj) = 0;
00397 
00401   virtual bool Remove (iCelPropertyClass* obj) = 0;
00402 
00406   virtual bool Remove (size_t n) = 0;
00407 
00411   virtual bool RemoveByInterface (scfInterfaceID scf_id, int iVersion) = 0;
00412 
00417   virtual bool RemoveByInterfaceAndTag (scfInterfaceID scf_id,
00418         int iVersion, const char* tag) = 0;
00419 
00423   virtual void RemoveAll () = 0;
00424 
00428   virtual size_t Find (iCelPropertyClass* obj) const = 0;
00429 
00436   virtual iCelPropertyClass* FindByName (const char *name) const = 0;
00437 
00442   virtual iCelPropertyClass* FindByNameAndTag (const char *name,
00443         const char* tag) const = 0;
00444 
00452   virtual iBase* FindByInterface (
00453         scfInterfaceID id, int version) const = 0;
00454 
00459   virtual iBase* FindByInterfaceAndTag (
00460         scfInterfaceID id, int version, const char* tag) const = 0;
00461 };
00462 
00467 template<class Interface>
00468 inline csPtr<Interface> celQueryPropertyClassTag (
00469   iCelPropertyClassList* plist, const char* tag)
00470 {
00471   iBase* base = plist->FindByInterfaceAndTag (
00472     scfInterfaceTraits<Interface>::GetID (),
00473     scfInterfaceTraits<Interface>::GetVersion (),
00474     tag);
00475 
00476   if (base == 0) return csPtr<Interface> (0); 
00477 
00478   Interface* x = (Interface*)base->QueryInterface (
00479     scfInterfaceTraits<Interface>::GetID (),
00480     scfInterfaceTraits<Interface>::GetVersion ());
00481 
00482   base->DecRef ();      // Release our base interface.
00483   return csPtr<Interface> (x);
00484 }
00485 
00492 template<class Interface>
00493 inline csPtr<Interface> celQueryPropertyClass (
00494   iCelPropertyClassList* plist)
00495 {
00496   iBase* base = plist->FindByInterface (
00497     scfInterfaceTraits<Interface>::GetID (),
00498     scfInterfaceTraits<Interface>::GetVersion ());
00499 
00500   if (base == 0) return csPtr<Interface> (0); 
00501 
00502   Interface* x = (Interface*)base->QueryInterface (
00503     scfInterfaceTraits<Interface>::GetID (),
00504     scfInterfaceTraits<Interface>::GetVersion ());
00505 
00506   base->DecRef ();      // Release our base interface.
00507   return csPtr<Interface> (x);
00508 }
00509 
00516 template<class Interface>
00517 inline csPtr<Interface> celQueryPropertyClassEntity (
00518   iCelEntity* entity)
00519 {
00520   return celQueryPropertyClass<Interface> (entity->GetPropertyClassList ());
00521 }
00522 
00523 #endif // __CEL_PL_PROPCLASS__
00524 

Generated for CEL: Crystal Entity Layer by doxygen 1.4.7