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 TypeFunction nameArguments
hzEcodehdbObject::Init(hdbClass*,)

Declared in file: hzDatabase.h
Defined in file : hdbObject.cpp

Function Logic:

0:START 1:unknown 2:items 3:unknown 4:Return hzerr(E_ARGUMENT,No data class supplied) 5:unknown 6:Return hzerr(E_NOINIT,Data class is not initialized) 7:unknown 8:Return hzerr(E_DUPLICATE,Object already initialized) 9:items m_pClass m_pRoot 10:unknown 11:pMbr 12:unknown 13:Return hzerr(E_CORRUPT,No member in position %d,nMbr) 14:unknown 15:Return hzerr(E_CORRUPT,Member in position %d has no name,nMbr) 16:Return E_OK

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 ;
}