Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cXObjDef.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cXObjDef_H
7 #define _INC_cXObjDef_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cXObject.h"
13 
14 namespace GrayLib
15 {
17  {
22 
23  friend class cXObjMgr;
24  typedef cXObject SUPER_t;
25 
26  public:
29  enum P_TYPE_
30  {
31 #define cXObjDefProp(a,b,c) P_##a,
32 #include "cXObjDefProps.tbl"
33 #undef cXObjDefProp
35  };
36  static cScriptableProp sm_Props[P_QTY + 1];
37  enum M_TYPE_
38  {
40 #define cXObjDefMethod(a,b,c) M_##a,
41 #include "cXObjDefMethods.tbl"
42 #undef cXObjDefMethod
44  };
45  static cScriptableMethod sm_Methods[M_QTY + 1];
46 
48 
49  private:
50  cAtomRef m_aSymName;
51 
52 #ifdef _DEBUG
53  cStringA m_sSymNameDebug;
54 #endif
55 
56  private:
57  void put_SymNamePrivate(cAtomRef aSymName);
58  bool ClearSymName();
59 
60  public:
61  cXObjDef(UID_t rid, cAtomRef aSymName);
62  virtual ~cXObjDef();
63 
64  virtual HRESULT DisposeThis() override;
65  STDMETHOD(SetObjStateLoaded)();
66 
68  bool hasSymName() const noexcept
69  {
71  return !m_aSymName.IsEmpty();
72  }
74  {
75  return m_aSymName;
76  }
77  STDMETHOD_(cStringA, get_SymName)() const override;
78 
79  static cAtomRef GRAYCALL MakeSymName(const ATOMCHAR_t* pszTypeName, ITERATE_t iEnum);
80 
81  STDMETHOD(put_SymName)(cAtomRef aSymName, bool bOverwrite = false) override;
82  HRESULT put_SymName2(cAtomRef aSymName);
83 
84  //***********************
85 
86  STDMETHOD_(cString, get_Name)() const override // default to same as the SYMNAME name.
87  {
89  return cString(get_SymName());
90  }
91 
92  virtual cString get_Description() const
93  {
95  return "";
96  }
97  virtual void put_Description(cString sDescription)
98  {
101  UNREFERENCED_PARAMETER(sDescription);
102  }
103  virtual cString get_DescriptionFull() const
104  {
106  return get_Description();
107  }
108 
111  virtual bool isResourceLoaded() const
112  {
114  return isObjStateLoaded();
115  }
116  virtual void UnloadXObject()
117  {
120  put_ObjState(XObjState_Init);
121  }
122  virtual HRESULT LoadXObject();
123  virtual HRESULT ReloadXObject();
124  virtual HRESULT SaveXObject();
125  virtual void CopyXObject(const cXObjDef* pDef);
126 
127  virtual int get_BaseRefCount() const override
128  {
132  int iCount = SUPER_t::get_BaseRefCount();
133  if (isValidUID()) // hash table makes a ref.
134  iCount++;
135  if (!m_aSymName.IsEmpty())
136  iCount++;
137  return iCount;
138  }
139 
140  STDMETHOD(s_PropPut)(const cScriptableProp* pProp, const cVariant& vVal) override;
141  STDMETHOD(s_PropGet)(const cScriptableProp* pProp, OUT cVariant& vValRet) override;
142  STDMETHOD(s_Invoke)(const cScriptableMethod* pMethod, const cVariant& vArgs, OUT cVariant& vValRet) override;
143  STDMETHOD(s_WriteProps)(IScriptableSetter& reg) override;
144 
145  virtual size_t GetHeapStats(OUT ITERATE_t& iAllocCount) const override
146  {
148  return SUPER_t::GetHeapStats(iAllocCount) + m_aSymName.GetHeapStats(iAllocCount);
149  }
150  };
151 
153 }
154 
155 #ifdef GRAY_DLL // force implementation/instantiate for DLL/SO.
156 namespace Gray
157 {
158  template class GRAYLIB_LINK cRefPtr<GrayLib::cXObjDef>;
159  template class GRAYLIB_LINK cRefPtr<GrayLib::cXObject>;
160 }
161 #endif
162 
163 #endif // cXObjDef
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define CSCRIPT_CLASS_DEF1(TYPE, _BASETYPE)
Definition: cScriptableInterface.h:277
Definition: cScriptableInterface.h:97
Definition: cVariant.h:26
Definition: cXObjDef.h:17
STDMETHOD_(cStringA, get_SymName)() const override
virtual size_t GetHeapStats(OUT ITERATE_t &iAllocCount) const override
allocs for all children. does NOT include sizeof(*this)
Definition: cXObjDef.h:145
virtual cString get_Description() const
Definition: cXObjDef.h:92
CHEAPOBJECT_IMPL
Definition: cXObjDef.h:27
virtual void UnloadXObject()
Definition: cXObjDef.h:116
cAtomRef get_SymNameA() const
Definition: cXObjDef.h:73
TIMESYS_t m_timeLastUsed
system time when last used. for caching
Definition: cXObjDef.h:47
virtual int get_BaseRefCount() const override
Definition: cXObjDef.h:127
P_TYPE_
Definition: cXObjDef.h:30
@ P_QTY
Definition: cXObjDef.h:34
M_TYPE_
Definition: cXObjDef.h:38
@ M_QTY
Definition: cXObjDef.h:43
virtual bool isResourceLoaded() const
Definition: cXObjDef.h:111
STDMETHOD_(cString, get_Name)() const override
Definition: cXObjDef.h:86
bool hasSymName() const noexcept
Get the SYMNAME of the resource item. (Used for saving,scripting) may be number or name.
Definition: cXObjDef.h:68
virtual void put_Description(cString sDescription)
Definition: cXObjDef.h:97
virtual cString get_DescriptionFull() const
Definition: cXObjDef.h:103
Definition: cXObjMgr.h:135
Definition: cXObject.h:78
Definition: cAtom.h:63
bool IsEmpty() const
Definition: cAtom.h:137
size_t GetHeapStats(OUT ITERATE_t &iAllocCount) const
Definition: cAtom.cpp:171
Definition: IScriptableObj.h:62
Definition: cMesh.h:22
class __DECL_IMPORT cXObjDef
Definition: cXObject.h:34
@ XObjState_Init
0=just initialize. No values loaded yet.
Definition: cXObject.h:59
cRefPtr< cXObjDef > cXObjDefPtr
Definition: cXObjDef.h:152
HASHCODE32_t UID_t
Sort of the same as a HASHCODE_t. not the same as UIDINDEX_t.
Definition: cUID.h:18
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
int ITERATE_t
like size_t but signed
Definition: Index.h:28
char ATOMCHAR_t
the char form (UNICODE or not) for an atom. (for symbolic names)
Definition: StrConst.h:15
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27
cStringT< GChar_t > cString
Definition: cString.h:636