Initialize a single object container Single object containers are assigned a data class (the operational native), and a name. The name was added so that hdbObject instances in Dissemino user sessions could be referenced by form handler commands.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbObject::Init | (hdbClass*,) |
Declared in file: hzDatabase.h
Defined in file : hdbObject.cpp
Function Logic:
Function body:
hzEcode hdbObject::Init (hdbClass* pClass)
{
// Initialize a single object container
//
// Single object containers are assigned a data class (the operational native), and a name. The name was added so that hdbObject instances in Dissemino user sessions could be
// referenced by form handler commands.
//
// Argument: objClass The data class
//
// Returns: E_CORRUPT If called without a hdbObject instance
// E_ARGUMENT If the class is not supplied
// E_NOINIT If the supplied class is not initialized
// E_DUPLICATE If this hdbObject is already initialized
// E_OK If the hdbObject is initialized to the class
_hzfunc("hdbObject::Init") ;
const hdbMember* pMbr ; // This class member
uint32_t nMbr ; // Member iterator
hzEcode rc = E_OK ; // Return code
// Check class and class init state
if (!this) hzexit(E_CORRUPT, "No instance") ;
if (!pClass) return hzerr(E_ARGUMENT, "No data class supplied") ;
if (!pClass->IsInit()) return hzerr(E_NOINIT, "Data class is not initialized") ;
if (m_pClass) return hzerr(E_DUPLICATE, "Object already initialized") ;
// Clear any pre-existing initialization and data
Clear() ;
// Set the class
m_pClass = pClass ;
// Allocate data space for members
m_pRoot = _obj_data::GetInstance(m_pClass) ;
// Go thru members
for (nMbr = 0; rc == E_OK && nMbr < pClass->MbrCount() ; nMbr++)
{
pMbr = pClass->GetMember(nMbr) ;
if (!pMbr)
return hzerr(E_CORRUPT, "No member in position %d", nMbr) ;
if (!pMbr->txtName())
return hzerr(E_CORRUPT, "Member in position %d has no name", nMbr) ;
}
return E_OK ;
}