Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cXObjMgr Class Reference

#include <cXObjMgr.h>

Inheritance diagram for GrayLib::cXObjMgr:
Gray::cSingletonSmart< cXObjMgr > IXObjMgr Gray::cSingleton< TYPE > Gray::cRefBase Gray::cSingletonStatic< TYPE > Gray::cSingletonRegister IUnknown Gray::CObject Gray::cHeapObject Gray::IHeapObject GrayLib::cXObjMgrPack

Public Types

enum  M_TYPE_ { M_QTY }
 

Public Member Functions

virtual cScriptableInterfaceDefPtr _stdcall get_ScriptInterfaceDef () const
 
 cXObjMgr (cXObjDef *pRoot=nullptr)
 
virtual ~cXObjMgr ()
 
virtual HRESULT InitXObjMgr (cXObjDef *pRoot)
 
virtual void DisposeAllX ()
 
virtual cXObjectPtr FindByUID (UID_t uid) const
 
cXObjectPtr GetAtHash (const cHashIterator &e) const
 
XOBJTIDX_TYPE FindXObjTypeIdx (const ATOMCHAR_t *pszXObjTypeName) const
 
XOBJTIDX_TYPE FindXObjTypeIdx (XOBJTID_t nXObjTypeId) const
 
cXObjTypeDefEnumXObjTypeDef (XOBJTIDX_TYPE index) const
 
cXObjTypeDefFindXObjTypeDef (const ATOMCHAR_t *pszXObjTypeName) const
 
cXObjTypeDefFindXObjTypeDef (XOBJTID_t nXObjTypeId) const
 
const ATOMCHAR_tFindXObjTypeName (XOBJTID_t nXObjTypeId) const
 
XOBJTID_t FindXObjTypeId (const ATOMCHAR_t *pszXObjTypeName) const
 
bool IsXObjTypeDemandLoaded (XOBJTID_t nXObjTypeId) const
 
XOBJTIDX_TYPE RegisterXObjTypeDef (cXObjTypeDef *pXObjTypeDef)
 
ITERATE_t UnloadXObjTypeDef (XOBJTID_t nXObjTypeId)
 
ITERATE_t get_XObjCount () const
 
cXObjDefPtr FindDefByUID (UID_t rid) const
 
HRESULT AddXObjSymName (cXObjDef *pXObjDef)
 
bool RemoveXObjSymName (const ATOMCHAR_t *pszSymName)
 
cXObjDefPtr FindBySymName0 (const ATOMCHAR_t *pszSymName) const
 
cXObjDefPtr FindBySymName (const ATOMCHAR_t *pszSymName) const
 
cXObjDefPtr FindBySymNamePartial (const ATOMCHAR_t *pszNamePartial) const
 
cXObjectPtr FindByVar (const cVariant &vID) const
 
virtual HRESULT CreateXObjDef (OUT cXObjDefPtr &rpXObjDefNew, const cXObjTypeDef *pXObjTypeDef, cAtomRef aSymName)
 
virtual HRESULT CreateXObjDefX (OUT cXObjDefPtr &rpXObjDefNew, const cXObjTypeDef *pXObjTypeDef, cAtomRef aSymName, IScriptableEnumerator *pProps)
 
virtual HRESULT s_Invoke_GetObjTypes (OUT cVariant &vValRet)
 
virtual HRESULT s_Invoke_FindObjects (const cVariant &vArgs, OUT cVariant &vValRet)
 
HRESULT s_Invoke_DumpConst (const cVariant &vArgs)
 
virtual UID_t MakeUID (XOBJTID_t nXObjTypeId, UIDINDEX_t nIndex)
 
HRESULT AssignFreeUID (cXObject *pObj, UIDINDEX_t nIndex)
 
virtual HRESULT AddXObj (cXObject *pXObj)
 
HRESULT AddXObjCheck (cXObject *pXObj, UIDINDEX_t nIndex=k_HASHCODE_CLEAR)
 
virtual void RemoveXObj (cXObject *pXObj)
 
virtual HRESULT AddXObjDef (cXObjDef *pXObjDef)
 
HRESULT AddXObjDefCheck (cXObjDef *pXObjDef, UIDINDEX_t nIndex)
 
virtual void RemoveXObjDef (cXObjDef *pXObjDef)
 
STDMETHOD() FindByUID (UID_t uid, OUT IXObject **ppObj) override
 
STDMETHOD() FindByStr (const ATOMCHAR_t *pszID, OUT IXObject **ppObj) override
 
STDMETHOD() FindBySymName (const ATOMCHAR_t *pszSymName, OUT IXObject **ppObj) override
 
STDMETHOD() CreateInstance (IUnknown *pUnkOuter, const IID &riid, OUT void **ppvObject) override
 
STDMETHOD() LockServer (BOOL fLock) override
 
STDMETHOD() QueryInterface (const IID &riid, OUT void __RPC_FAR *__RPC_FAR *ppvObject) override
 
STDMETHOD() s_Invoke (const cScriptableMethod *pMethod, const cVariant &vArgs, OUT cVariant &vValRet)
 
 UNITTEST_FRIEND (cXObjMgr)
 
 IUNKNOWN_DISAMBIG_R (cRefBase)
 
- Public Member Functions inherited from Gray::CObject
virtual ~CObject ()
 
virtual bool isValidCheck () const noexcept
 < memory allocation and structure definitions are valid. More...
 
virtual void AssertValid () const
 < memory allocation and structure definitions are valid. More...
 
virtual void Serialize (cArchive &a)
 
- Public Member Functions inherited from Gray::cHeapObject
 cHeapObject ()
 
virtual ~cHeapObject ()
 
bool IsValidInsideN (INT_PTR index) const
 
bool IsValidInsidePtr (void const *pTest) const
 
virtual size_t GetHeapStatsThis (OUT ITERATE_t &iAllocCount) const
 
virtual bool isValidCheck () const noexcept
 
- Public Member Functions inherited from Gray::cRefBase
 cRefBase (int iRefCount=0) noexcept
 
virtual ~cRefBase ()
 
int get_RefCount () const noexcept
 
HASHCODE_t get_HashCode () const noexcept
 
 STDMETHOD_ (HASHCODE_t, get_HashCodeX)() const noexcept
 
virtual void onFinalRelease ()
 
bool isValidObj () const noexcept
 
 STDMETHOD_ (ULONG, AddRef)(void) override
 
 STDMETHOD_ (ULONG, Release)(void) override
 
STDMETHOD() QueryInterface (const IID &riid, void __RPC_FAR *__RPC_FAR *ppvObject) override
 
void IncRefCount ()
 
void DecRefCount ()
 
bool isStaticConstruct () const noexcept
 
void StaticConstruct ()
 
void StaticDestruct ()
 
bool isDestructing () noexcept
 
void SetDestructing ()
 

Static Public Member Functions

static HRESULT CheckValidSignature (UINT32 nGrayLibVer, size_t nSizeofThis)
 
- Static Public Member Functions inherited from Gray::cSingleton< TYPE >
static TYPE *__stdcall get_Single ()
 
template<class TYPE2 >
static TYPE2 *__stdcall get_SingleT ()
 
static TYPE &__stdcall I ()
 
- Static Public Member Functions inherited from Gray::cSingletonStatic< TYPE >
static bool isSingleCreated () noexcept
 
static TYPEget_SingleU () noexcept
 
static TYPEget_Single ()
 
template<class TYPE2 >
static TYPE2 *__stdcall get_SingleCast ()
 
static TYPEI () noexcept
 
- Static Public Member Functions inherited from Gray::cSingletonRegister
static void __stdcall ReleaseModule (HMODULE hMod)
 

Public Attributes

const cObjectSignature m_Sig
 Used to check for compatible config and alignments. More...
 
cHashTableRef< cXObject, UID_t, 6 > m_XObjHash
 the hash of cXObject objects by UID. Some may be in private hash! cUIDManagerArray? IXObjModPlugin More...
 

Static Public Attributes

static cScriptableMethod sm_Methods [M_QTY+1]
 
static cScriptableInterfaceDef sm_ScriptInterfaceDef
 
static cXObjTypeDef sm_DEFAULT = { k_XOBJTID_DEFAULT, "Default", XOBJTYPF_0, nullptr, "Dynamic XObject" }
 Used to create a bare XObject. More...
 
- Static Public Attributes inherited from Gray::cSingletonRegister
static cThreadLockFast sm_LockSingle
 common lock for all cSingleton. More...
 

Protected Attributes

cArraySortSymName< cXObjDefm_aXObjSymNames
 Store all cXObjDef(s) sorted by SymName or get_SymName() More...
 
cThreadLockCount m_LockXObj
 used to lock access m_XObjHash More...
 
cArrayPtr< cXObjTypeDefm_aXObjTypeDefs
 Metadata info about the cXObject types i use. XOBJTID_t, XOBJTIDX_TYPE = index in this array. More...
 
- Protected Attributes inherited from Gray::cSingletonRegister
HMODULE m_hModuleLoaded
 What modules loaded this ? So singletons can be destroyed if DLL/SO unloads. More...
 

Friends

class cSingleton< cXObjMgr >
 

Additional Inherited Members

- Protected Member Functions inherited from Gray::cSingletonSmart< cXObjMgr >
 cSingletonSmart (cXObjMgr *pObject, const TYPEINFO_t &rAddrCode, int iRefCountStart=0)
 
const void * get_HeapPtr () const noexcept override
 Get the top level (outermost, freeable) class pointer. I can delete get_HeapPtr(). More...
 
- Protected Member Functions inherited from Gray::cSingleton< TYPE >
 cSingleton (TYPE *pObject, const TYPEINFO_t &rAddrCode=typeid(TYPE)) noexcept
 
virtual ~cSingleton ()
 
- Protected Member Functions inherited from Gray::cSingletonStatic< TYPE >
 cSingletonStatic (TYPE *pObject) noexcept
 
virtual ~cSingletonStatic () noexcept
 
- Protected Member Functions inherited from Gray::cSingletonRegister
 cSingletonRegister (const TYPEINFO_t &rAddrCode) noexcept
 
virtual ~cSingletonRegister ()
 
void RegisterSingleton ()
 
- Static Protected Attributes inherited from Gray::cSingletonStatic< TYPE >
static TYPEsm_pThe = nullptr
 pointer to the one and only object of this TYPE. ASSUME automatically init to = nullptr. More...
 

Detailed Description

A pool of indexed resource objects. Index resource objects by UID and SYMNAME. Allow alternate SYMNAME via cScriptContext::GetContextRoot(). define meta data for the resource types.

Note
may add its own properties to root object via cScriptableObj

Member Enumeration Documentation

◆ M_TYPE_

Enumerator
M_QTY 

Constructor & Destructor Documentation

◆ cXObjMgr()

GrayLib::cXObjMgr::cXObjMgr ( cXObjDef pRoot = nullptr)

◆ ~cXObjMgr()

GrayLib::cXObjMgr::~cXObjMgr ( )
virtual
Note
Should have already called DisposeAllX()

Member Function Documentation

◆ AddXObj()

HRESULT GrayLib::cXObjMgr::AddXObj ( cXObject pXObj)
virtual

Assume get_UIDValue() set, Add to the hashes.

Note
May already be in the m_XObjHash thats OK. usually called by SetObjStateLoaded()

◆ AddXObjCheck()

HRESULT GrayLib::cXObjMgr::AddXObjCheck ( cXObject pXObj,
UIDINDEX_t  nIndex = k_HASHCODE_CLEAR 
)

Add a new cXObject based object to the UID hash table. if it doesn't already have a UID, find a free spot in the hash

  • nIndex = k_HASHCODE_CLEAR = find a free id.

◆ AddXObjDef()

HRESULT GrayLib::cXObjMgr::AddXObjDef ( cXObjDef pXObjDef)
virtual

Assume get_UIDValue(), SymName is already set. Add to the hashes.

Note
May already be in the m_XObjHash thats OK. usually called by SetObjStateLoaded()

◆ AddXObjDefCheck()

HRESULT GrayLib::cXObjMgr::AddXObjDefCheck ( cXObjDef pXObjDef,
UIDINDEX_t  nIndex 
)

Add a new cXObjDef based object to the UID hash table and SymName table. if it doesn't already have a UID, find a free spot in the hash

◆ AddXObjSymName()

HRESULT GrayLib::cXObjMgr::AddXObjSymName ( cXObjDef pXObjDef)

Add this XObj to the hash with a given SYMNAME.

◆ AssignFreeUID()

HRESULT GrayLib::cXObjMgr::AssignFreeUID ( cXObject pObj,
UIDINDEX_t  nIndex 
)

Make a new free UID for some object. Optionally incorporate UIDINDEX_t in UID.

◆ CheckValidSignature()

static HRESULT GrayLib::cXObjMgr::CheckValidSignature ( UINT32  nGrayLibVer,
size_t  nSizeofThis 
)
inlinestatic

Must be agreed to by all users. sizeof(cAppState) for checking alignments of structures. Ensure that some external DLL/SO caller has the same structure packing that we have.

◆ CreateInstance()

HRESULT GrayLib::cXObjMgr::CreateInstance ( IUnknown pUnkOuter,
const IID riid,
OUT void **  ppvObject 
)
override

Create some type of object.

  • riid = RES_ItemType, Char, Server, Skill

◆ CreateXObjDef()

HRESULT GrayLib::cXObjMgr::CreateXObjDef ( OUT cXObjDefPtr rpXObjDefNew,
const cXObjTypeDef pXObjTypeDef,
cAtomRef  aSymName 
)
virtual

IXObjModPlugin

Note
This may be overridden

◆ CreateXObjDefX()

HRESULT GrayLib::cXObjMgr::CreateXObjDefX ( OUT cXObjDefPtr rpXObjDefNew,
const cXObjTypeDef pXObjTypeDef,
cAtomRef  aSymName,
IScriptableEnumerator pProps 
)
virtual

Create a cXObjDef object of a certain type. we are probably loading it from a script ? pProps

Note
Expect SetObjStateLoaded() will be called later.

◆ DisposeAllX()

void GrayLib::cXObjMgr::DisposeAllX ( )
virtual

Reimplemented in GrayLib::cXObjMgrPack.

◆ EnumXObjTypeDef()

cXObjTypeDef * GrayLib::cXObjMgr::EnumXObjTypeDef ( XOBJTIDX_TYPE  index) const

◆ FindByStr()

HRESULT GrayLib::cXObjMgr::FindByStr ( const ATOMCHAR_t pszID,
OUT IXObject **  ppObj 
)
override

◆ FindBySymName() [1/2]

cXObjDefPtr GrayLib::cXObjMgr::FindBySymName ( const ATOMCHAR_t pszSymName) const

Find SYMNAME for object.

◆ FindBySymName() [2/2]

HRESULT GrayLib::cXObjMgr::FindBySymName ( const ATOMCHAR_t pszSymName,
OUT IXObject **  ppObj 
)
override

◆ FindBySymName0()

cXObjDefPtr GrayLib::cXObjMgr::FindBySymName0 ( const ATOMCHAR_t pszSymName) const

Find by primary SymName and nothing else.

◆ FindBySymNamePartial()

cXObjDefPtr GrayLib::cXObjMgr::FindBySymNamePartial ( const ATOMCHAR_t pszNamePartial) const

Find a partial match of a SYMNAME

◆ FindByUID() [1/2]

cXObjectPtr GrayLib::cXObjMgr::FindByUID ( UID_t  uid) const
virtual

Get the cXObject by its UID. This can be overridden to add support for special cUIDRangeMask ranges.

Reimplemented in GrayLib::cXObjMgrPack.

◆ FindByUID() [2/2]

HRESULT GrayLib::cXObjMgr::FindByUID ( UID_t  uid,
OUT IXObject **  ppObj 
)
override
Note
The caller is responsible for calling IUnknown::Release(); and/or using cIUnkPtr

◆ FindByVar()

cXObjectPtr GrayLib::cXObjMgr::FindByVar ( const cVariant vID) const

Find an object by SymName or UID. (or friendly name?) vID = SYMNAME or UID.

◆ FindDefByUID()

cXObjDefPtr GrayLib::cXObjMgr::FindDefByUID ( UID_t  rid) const

Get the cXObjDef from a UID. e.g. cUID::k_ROOT

◆ FindXObjTypeDef() [1/2]

cXObjTypeDef * GrayLib::cXObjMgr::FindXObjTypeDef ( const ATOMCHAR_t pszXObjTypeName) const

find the type by name.

◆ FindXObjTypeDef() [2/2]

cXObjTypeDef * GrayLib::cXObjMgr::FindXObjTypeDef ( XOBJTID_t  nXObjTypeId) const

Find the FOURCC code for the XObject type in the XObject defs

◆ FindXObjTypeId()

XOBJTID_t GrayLib::cXObjMgr::FindXObjTypeId ( const ATOMCHAR_t pszXObjTypeName) const

◆ FindXObjTypeIdx() [1/2]

XOBJTIDX_TYPE GrayLib::cXObjMgr::FindXObjTypeIdx ( const ATOMCHAR_t pszXObjTypeName) const

Find the cXObjTypeDef by name

◆ FindXObjTypeIdx() [2/2]

XOBJTIDX_TYPE GrayLib::cXObjMgr::FindXObjTypeIdx ( XOBJTID_t  nXObjTypeId) const

Find the cXObjTypeDef by XOBJTID_t (FOURCC)

◆ FindXObjTypeName()

const ATOMCHAR_t * GrayLib::cXObjMgr::FindXObjTypeName ( XOBJTID_t  nXObjTypeId) const

Find the FOURCC code for the XObject type in the XObject defs.

Returns
the full name.

◆ get_ScriptInterfaceDef()

virtual cScriptableInterfaceDefPtr _stdcall GrayLib::cXObjMgr::get_ScriptInterfaceDef ( ) const
inlinevirtual

◆ get_XObjCount()

ITERATE_t GrayLib::cXObjMgr::get_XObjCount ( ) const
inline

◆ GetAtHash()

cXObjectPtr GrayLib::cXObjMgr::GetAtHash ( const cHashIterator e) const
inline

Walk hash table.

◆ InitXObjMgr()

HRESULT GrayLib::cXObjMgr::InitXObjMgr ( cXObjDef pRoot)
virtual

Create and Assign the k_ROOT object. ASSUME RegisterXObjTypeDef() already called.

Reimplemented in GrayLib::cXObjMgrPack.

◆ IsXObjTypeDemandLoaded()

bool GrayLib::cXObjMgr::IsXObjTypeDemandLoaded ( XOBJTID_t  nXObjTypeId) const

Is this type loaded only when needed? (from db or file)

◆ IUNKNOWN_DISAMBIG_R()

GrayLib::cXObjMgr::IUNKNOWN_DISAMBIG_R ( cRefBase  )

◆ LockServer()

HRESULT GrayLib::cXObjMgr::LockServer ( BOOL  fLock)
override

◆ MakeUID()

UID_t GrayLib::cXObjMgr::MakeUID ( XOBJTID_t  nXObjTypeId,
UIDINDEX_t  nIndex 
)
virtual

Make a UID of a specific XOBJTID_t. We are about to create a new XObject.

◆ QueryInterface()

STDMETHODIMP GrayLib::cXObjMgr::QueryInterface ( const IID riid,
OUT void __RPC_FAR *__RPC_FAR *  ppvObject 
)
override

support for IXObjMgr COM like IUnknown interface support. a dynamic cast to another interface type.

◆ RegisterXObjTypeDef()

XOBJTIDX_TYPE GrayLib::cXObjMgr::RegisterXObjTypeDef ( cXObjTypeDef pXObjTypeDef)

Register a cXObjTypeDef definition. Assume static and never removed.

Returns
XOBJTIDX_TYPE and pXObjTypeDef->m_eXObjTypeIdx is set.

◆ RemoveXObj()

void GrayLib::cXObjMgr::RemoveXObj ( cXObject pXObj)
virtual

called by DisposeThis

◆ RemoveXObjDef()

void GrayLib::cXObjMgr::RemoveXObjDef ( cXObjDef pXObjDef)
virtual

called by DisposeThis

Reimplemented in GrayLib::cXObjMgrPack.

◆ RemoveXObjSymName()

bool GrayLib::cXObjMgr::RemoveXObjSymName ( const ATOMCHAR_t pszSymName)

remove an object by SymName

◆ s_Invoke()

HRESULT GrayLib::cXObjMgr::s_Invoke ( const cScriptableMethod pMethod,
const cVariant vArgs,
OUT cVariant vValRet 
)

ASSUME the root object exposes this.

◆ s_Invoke_DumpConst()

HRESULT GrayLib::cXObjMgr::s_Invoke_DumpConst ( const cVariant vArgs)

Dump to current cScriptContext console or file.

◆ s_Invoke_FindObjects()

HRESULT GrayLib::cXObjMgr::s_Invoke_FindObjects ( const cVariant vArgs,
OUT cVariant vValRet 
)
virtual

support CATOM_STATIC(FindObjects) method.

  • (sTypeName,sNameWildCard) or (SYMNAME) or (UID)

◆ s_Invoke_GetObjTypes()

HRESULT GrayLib::cXObjMgr::s_Invoke_GetObjTypes ( OUT cVariant vValRet)
virtual

support CATOM_STATIC(GetObjTypes) method. Get a list of XObject types for FindObject.

◆ UNITTEST_FRIEND()

GrayLib::cXObjMgr::UNITTEST_FRIEND ( cXObjMgr  )

◆ UnloadXObjTypeDef()

ITERATE_t GrayLib::cXObjMgr::UnloadXObjTypeDef ( XOBJTID_t  nXObjTypeId)

unload all XObject of this type.

Friends And Related Function Documentation

◆ cSingleton< cXObjMgr >

friend class cSingleton< cXObjMgr >
friend

Member Data Documentation

◆ m_aXObjSymNames

cArraySortSymName<cXObjDef> GrayLib::cXObjMgr::m_aXObjSymNames
protected

Store all cXObjDef(s) sorted by SymName or get_SymName()

all cXObjDef sorted by symbolic resource name get_SymName()

◆ m_aXObjTypeDefs

cArrayPtr<cXObjTypeDef> GrayLib::cXObjMgr::m_aXObjTypeDefs
protected

Metadata info about the cXObject types i use. XOBJTID_t, XOBJTIDX_TYPE = index in this array.

◆ m_LockXObj

cThreadLockCount GrayLib::cXObjMgr::m_LockXObj
mutableprotected

used to lock access m_XObjHash

◆ m_Sig

const cObjectSignature GrayLib::cXObjMgr::m_Sig

Used to check for compatible config and alignments.

Used to check for compatible config and alignments. _INC_GrayLibBase_H, sizeof(cXObjMgr)

◆ m_XObjHash

cHashTableRef<cXObject, UID_t, 6> GrayLib::cXObjMgr::m_XObjHash

the hash of cXObject objects by UID. Some may be in private hash! cUIDManagerArray? IXObjModPlugin

Store cXObject and cXObjDef(s) sorted by UID.

Note
some of the UID space may be reserved for cXObject and/or managed by IXObjModPlugin

◆ sm_DEFAULT

cXObjTypeDef GrayLib::cXObjMgr::sm_DEFAULT = { k_XOBJTID_DEFAULT, "Default", XOBJTYPF_0, nullptr, "Dynamic XObject" }
static

Used to create a bare XObject.

◆ sm_Methods

cScriptableMethod GrayLib::cXObjMgr::sm_Methods
static
Initial value:
=
{
#define cXObjMgrMethod(a,b,c)
}
#define CSCRIPT_PROP_END
Definition: cScriptableInterface.h:264

◆ sm_ScriptInterfaceDef

cScriptableInterfaceDef GrayLib::cXObjMgr::sm_ScriptInterfaceDef
static

The documentation for this class was generated from the following files: