Add a child to this visible entity. Returns: E_OK
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdsVE::AddChild | (hdsVE*,) |
Declared in file: hzDissemino.h
Defined in file : hdsCore.cpp
Function Logic:
Function body:
hzEcode hdsVE::AddChild (hdsVE* pChild)
{
// Category: Dissemino System Initialization
//
// Add a child to this visible entity.
//
// Arguments: 1) pChild The pointer to the child visible entity
//
// Returns: E_OK
_hzfunc("hdsVE::AddChild") ;
hdsVE* pVE ; // Visible entity pointer
if (!pChild)
hzexit(E_ARGUMENT, "%s: Null child supplied to Visible Entity", *m_Tag) ;
if (m_flagVE & VE_COMPLETE)
hzexit(E_SEQUENCE, "%s: Visible Entity is already complete, cannot add child %s", *m_Tag, *pChild->m_Tag) ;
if (pChild == this)
hzexit(E_CORRUPT, "%s: Child is same as parent", *m_Tag) ;
if (!pChild->m_VID)
hzexit(E_CORRUPT, "%s: Supplied child (%s) has no ID", *m_Tag, *pChild->m_Tag) ;
// Child VEs?
if (!m_Children)
{
// The current VE has no children so add the first
m_Children = pChild->m_VID ;
}
else
{
// Run through existing children and set the sibling of the last child to the new child. Note that if the child VE we are adding is already among existing children, we note
// the duplicate and return without adding.
pVE = Children() ;
if (pVE->Sibling())
{
for (; pVE && pVE->Sibling() ; pVE = pVE->Sibling())
{
if (pVE == pChild)
return E_OK ;
}
}
if (!pVE)
hzexit(E_CORRUPT, "Last child already had a sibling value") ;
pVE->m_Sibling = pChild->m_VID ;
// pVE->SetSibling(pChild) ;
}
m_nChildren++ ;
return E_OK ;
}