00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_SHAREVAR_H__
00020 #define __CS_SHAREVAR_H__
00021
00022 #include "csutil/nobjvec.h"
00023 #include "csutil/csstring.h"
00024 #include "iengine/sharevar.h"
00025 #include "csutil/csobject.h"
00026
00027
00028
00029 SCF_VERSION (csSharedVariable, 0, 0, 2);
00030
00034 class csSharedVariable : public csObject
00035 {
00036 private:
00037 int type;
00038 float value;
00039 csColor color;
00040 csVector3 vec;
00041
00042 public:
00043
00044 SCF_DECLARE_IBASE_EXT (csObject);
00045
00050 csSharedVariable () : csObject()
00051 {
00052 SCF_CONSTRUCT_EMBEDDED_IBASE (scfiSharedVariable);
00053 value = 0;
00054 type = iSharedVariable::SV_UNKNOWN;
00055 }
00056
00057 void Set (float val)
00058 { value = val; type = iSharedVariable::SV_FLOAT; }
00059
00060 float Get () const
00061 { return (type == iSharedVariable::SV_FLOAT) ? value : 0; }
00062
00063 void SetColor (const csColor& col)
00064 { color.Set(col.red,col.green,col.blue); type = iSharedVariable::SV_COLOR; }
00065
00066 const csColor& GetColor() const
00067 { return (type == iSharedVariable::SV_COLOR) ? color : csColor (0,0,0),color; }
00068
00069 void SetVector (const csVector3& v)
00070 { vec = v; type = iSharedVariable::SV_VECTOR; }
00071
00072 const csVector3& GetVector() const
00073 { return (type == iSharedVariable::SV_VECTOR) ? vec : csVector3 (0,0,0),vec; }
00074
00075 int GetType () const
00076 { return type; }
00077
00078
00079
00080 struct eiSharedVariable : public iSharedVariable
00081 {
00082 SCF_DECLARE_EMBEDDED_IBASE (csSharedVariable);
00083
00084 virtual iObject* QueryObject () { return scfParent; }
00085 virtual void Set(float val)
00086 { scfParent->Set(val); }
00087 virtual float Get() const
00088 { return scfParent->Get(); }
00089 virtual void SetName (const char *iName)
00090 { scfParent->SetName(iName); }
00091 virtual const char *GetName () const
00092 { return scfParent->GetName(); }
00093 virtual void SetColor (const csColor& color)
00094 { scfParent->SetColor (color); }
00095 virtual const csColor& GetColor() const
00096 { return scfParent->GetColor(); }
00097 virtual void SetVector (const csVector3& v)
00098 { scfParent->SetVector (v); }
00099 virtual const csVector3& GetVector () const
00100 { return scfParent->GetVector (); }
00101 int GetType () const
00102 { return scfParent->GetType (); }
00103
00104 } scfiSharedVariable;
00105 friend struct eiSharedVariable;
00106 };
00107
00109 class csSharedVariableList : public csRefArrayObject<iSharedVariable>
00110 {
00111 public:
00112 SCF_DECLARE_IBASE;
00113
00115 csSharedVariableList ();
00117 virtual ~csSharedVariableList ();
00118
00120 csPtr<iSharedVariable> New() const;
00121
00122 class SharedVariableList : public iSharedVariableList
00123 {
00124 public:
00125 SCF_DECLARE_EMBEDDED_IBASE (csSharedVariableList);
00126
00127 virtual int GetCount () const;
00128 virtual iSharedVariable *Get (int n) const;
00129 virtual int Add (iSharedVariable *obj);
00130 virtual bool Remove (iSharedVariable *obj);
00131 virtual bool Remove (int n);
00132 virtual void RemoveAll ();
00133 virtual int Find (iSharedVariable *obj) const;
00134 virtual iSharedVariable *FindByName (const char *Name) const;
00135 virtual csPtr<iSharedVariable> New() const
00136 { return scfParent->New(); }
00137 } scfiSharedVariableList;
00138 };
00139
00140 #endif // __CS_SHAREVAR_H__