Synopsis
PDX_MSGT mda_AddPtr(MDA_PTR parent, MDA_PTR child, MDA_PTR *ptr)
Purpose
Establish an entity reference.
Description
A reference to the specified child will be made from parent. The location within the parent entity of the pointer to child is passed in ptr. Upon return, @a *ptr will be equal to child. If backpointers are enabled for the model child is defined in (see mda_GetModelDefaults), a backpointer will be generated from child to parent. The list of parents for child can be obtained by calling mda_GetParents with the child pointer. If backpointers are not enabled then the child's parent list will not be updated (@a *ptr will still be set to the child pointer). Child may be specified as MDA_NULL_PTR although there is currently no way of obtaining the list of entities pointing to MDA_NULL_PTR. Parent can not be specified as MDA_NULL_PTR. The following example shows how a pointer field is set using mda_AddPtr.
.nf Given a ddf entity of:
entity 1:0 NODE { float loc[3]; ptr next; }
The following code makes a reference from node1 to node2:
T_NODE *node1, *node2; MDA_PTR node1_ptr, node2_ptr;
mda_AllocateEntity (MDA_NOOPT, NODE, &node1, &node1_ptr); mda_AllocateEntity (MDA_NOOPT, NODE, &node2, &node2_ptr);
mda_AddPtr (node1_ptr, node2_ptr, &node1->next);
.fi
Input
parent
Entity referencing child
child
Entity referenced from parent
Output
ptr
Set to value of child
Return
MDA error code