Fetches a subclass object from the applicable member of this (host class) object. The supplied hdbObject (previously initialized to the subclass), is first cleared leaving its m_pRoot pointer as NULL. m_pRoot is then set to the fetched _obj_data, raising the copy count.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbObject::GetObject | (hdbObject&,hdbMember*,uint32_t,) |
Declared in file: hzDatabase.h
Defined in file : hdbObject.cpp
Function Logic:
Function body:
hzEcode hdbObject::GetObject (hdbObject& sub)hdbMember* pMbr, uint32_t nOset,
{
// Fetches a subclass object from the applicable member of this (host class) object.
//
// The supplied hdbObject (previously initialized to the subclass), is first cleared leaving its m_pRoot pointer as NULL. m_pRoot is then set to the fetched _obj_data, raising
// the copy count.
//
// Arguments: 1) sub The target subclass object container
// 2) pMbr The applicable host class member
// 3) nOset Position in array of subclass objects held by the host class member
//
_hzfunc("hdbObject::GetObject") ;
hzArray <_obj_data*>* pArr ; // Cast of core entry to object array
_obj_data* pSub ; // Subclass object pointer
uchar* pMCS ; // Member core space
uchar* pLitmus ; // Litmus bits
hzEcode rc ; // Return code
// Object has class?
if (!this) hzexit(E_CORRUPT, "No instance") ;
if (!m_pClass) return hzerr(E_NOINIT, "Single object container not init to a data class") ;
if (!sub.m_pClass) return hzerr(E_NOINIT, "Subclass object container not init to a data class") ;
if (!pMbr) return hzerr(E_ARGUMENT, "No member supplied") ;
if (pMbr->Class() != m_pClass)
return hzerr(E_CORRUPT, "Member %s does not belong to class %s", pMbr->txtName(), m_pClass->txtName()) ;
if (pMbr->Basetype() != BASETYPE_CLASS)
return hzerr(E_TYPE, "Member %s is atomic", pMbr->txtName()) ;
if (pMbr->Datatype() != sub.m_pClass)
return hzerr(E_TYPE, "Member %s is not of type class %s", pMbr->txtName(), sub.m_pClass->txtName()) ;
sub.Clear() ;
// Set litmus and core space pointers
pMCS = m_pRoot->m_Core + pMbr->OsetStd() ;
pLitmus = m_pRoot->m_Core + m_pClass->CoreLen() ;
if (pLitmus[pMbr->Posn()] & LITMUS_SET)
{
// Cast the array
pArr = (hzArray<_obj_data*>*) pMCS ;
if (nOset >&eq; pArr->Count())
return E_NOTFOUND ;
pSub = pArr->operator[](nOset) ;
sub.m_pRoot = pSub ;
sub.m_pRoot->m_copy++ ;
}
return E_OK ;
}