| ## Public API Reference

- Main Page
- Classes
- Files

# celtool/stdpcimp.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_CELTOOL_STDPC__
    00021 #define __CEL_CELTOOL_STDPC__
    00022
    00023 #include "cstypes.h"
    00024 #include "iutil/comp.h"
    00025 #include "csutil/scf.h"
    00026 #include "csutil/scf_implementation.h"
    00027 #include "csutil/refarr.h"
    00028 #include "csutil/weakref.h"
    00029 #include "physicallayer/propclas.h"
    00030 #include "physicallayer/propfact.h"
    00031 #include "physicallayer/pl.h"
    00032
    00033 struct iCelEntity;
    00034 struct iObjectRegistry;
    00035
    00036
    00037 struct Property
    00038 {
    00039   csStringID            id;
    00040   celDataType           datatype;
    00041   bool                  readonly;
    00042   const char*           desc;
    00043 };
    00044
    00050 class celPcCommon : public scfImplementation2<
    00051         celPcCommon, iCelPropertyClass, iCelTimerListener>
    00052 {
    00053 private:
    00054   csRefArray<iCelPropertyChangeCallback> callbacks;
    00055   // This flag is true if we currently don't know the state of
    00056   // the sibling property classes (property classes in the same
    00057   // entity). It is set to true by PropertyClassesHaveChanged()
    00058   // and cleared by HavePropertyClassesChanged().
    00059   bool propclasses_dirty;
    00060   char* tag;
    00061
    00062 protected:
    00063   iCelEntity* entity;
    00064   iObjectRegistry* object_reg;
    00065   csWeakRef<iCelPlLayer> pl;
    00066
    00067 protected:
    00068   void FirePropertyChangeCallback (int propertyId);
    00069
    00070   static void UpdateProperties (iObjectRegistry*) { return; }
    00071
    00072   void** propdata;
    00073   Property* props;
    00074   size_t* propcount;
    00075
    00076 public:
    00077   celPcCommon (iObjectRegistry* object_reg);
    00078   virtual ~celPcCommon ();
    00079
    00080   bool HavePropertyClassesChanged ()
    00081   {
    00082     if (!propclasses_dirty) return false;
    00083     propclasses_dirty = false;
    00084     return true;
    00085   }
    00086
    00087   virtual void SetTag (const char* tagname);
    00088   virtual const char* GetTag () const { return tag; }
    00089
    00090   virtual iCelEntity* GetEntity () { return entity; }
    00091   virtual void SetEntity (iCelEntity* entity);
    00092   virtual bool AddPropertyChangeCallback (iCelPropertyChangeCallback* cb);
    00093   virtual bool RemovePropertyChangeCallback (
    00094         iCelPropertyChangeCallback* cb);
    00095
    00096   virtual bool SetProperty (csStringID, long);
    00097   virtual bool SetProperty (csStringID, float);
    00098   virtual bool SetProperty (csStringID, bool);
    00099   virtual bool SetProperty (csStringID, const char*);
    00100   virtual bool SetProperty (csStringID, const csVector2&);
    00101   virtual bool SetProperty (csStringID, const csVector3&);
    00102   virtual bool SetProperty (csStringID, const csColor&);
    00103   virtual bool SetProperty (csStringID, iCelPropertyClass* pclass);
    00104   virtual bool SetProperty (csStringID, iCelEntity* entity);
    00105   virtual bool SetProperty (csStringID, iBase* ibase);
    00106   virtual celDataType GetPropertyOrActionType (csStringID);
    00107   virtual bool IsPropertyReadOnly (csStringID);
    00108   virtual long GetPropertyLong (csStringID);
    00109   virtual float GetPropertyFloat (csStringID);
    00110   virtual bool GetPropertyBool (csStringID);
    00111   virtual const char* GetPropertyString (csStringID);
    00112   virtual bool GetPropertyVector (csStringID, csVector2&);
    00113   virtual bool GetPropertyVector (csStringID, csVector3&);
    00114   virtual bool GetPropertyColor (csStringID, csColor&);
    00115   virtual iCelPropertyClass* GetPropertyPClass (csStringID);
    00116   virtual iCelEntity* GetPropertyEntity (csStringID);
    00117   virtual iBase* GetPropertyIBase (csStringID);
    00118   virtual bool PerformAction (csStringID, iCelParameterBlock*, celData& ret)
    00119   { return false; }
    00120   virtual const char* GetPropertyOrActionDescription (csStringID);
    00121   virtual size_t GetPropertyAndActionCount () const;
    00122   virtual csStringID GetPropertyOrActionID (size_t);
    00123   virtual void PropertyClassesHaveChanged ()
    00124   {
    00125     propclasses_dirty = true;
    00126   }
    00127
    00128   virtual csPtr<iCelDataBuffer> SaveFirstPass () { return 0; }
    00129   virtual bool LoadFirstPass (iCelDataBuffer*) { return 0; }
    00130
    00131   virtual csPtr<iCelDataBuffer> GetPersistentData (
    00132         celPersistenceType persistence_type)
    00133     { return 0; }
    00134   virtual celPersistenceResult SetPersistentData (csTicks data_time,
    00135         iCelDataBuffer* data, celPersistenceType persistence_type)
    00136     { return CEL_PERSIST_RESULT_OK; };
    00137
    00138   // --- For iCelTimerListener -----------------------------------------
    00139   virtual void TickEveryFrame () { }
    00140   virtual void TickOnce () { }
    00141 };
    00142
    00143 #endif // __CEL_CELTOOL_STDPC__
    00144