Synopsis

PDX_MSGT mda_ReplaceDbptr(long option, MDA_PTR old_db_ptr, MDA_PTR new_db_ptr)

Purpose

Replaces one database pointer with another.

Description

The entity with database pointer old_db_ptr will be reassigned so that after returning from this function it will be database pointer new_db_ptr. The entity contents are not changed. The pointer old_db_ptr will be considered deleted (and may later be reassigned when new entities are allocated). The database pointer specified by new_db_ptr must be reserved by either calling mda_ReserveEntity or using the MDA_RESERVED option to mda_DeleteEntity. This function allows an existing entity to be deleted (with the reserved option) and then replaced with another existing entity. The following code shows how this might be used:

.nf options = MDA_FORCE_DELETE | MDA_RESERVED | MDA_NO_DELETE_PARENT_PTRS mda_DeleteEntity (options, new_db_ptr); mda_ReplaceDbptr (MDA_NOOPT, old_db_ptr, new_db_ptr); .fi

After this sequence, the entity previously defined by old_db_ptr will be defined as new_db_ptr and old_db_ptr will be considered deleted. Note that the MDA_FORCE_DELETE and MDA_NO_DELETE_PARENT_PTRS are used to tell mda_DeleteEntity to delete the entity even if it is referenced from other entities and to not remove any backpointer references from new_db_ptr to its parents.

This function does not change any references from other entities to either old_db_ptr or new_db_ptr. If there are references to old_db_ptr, the application must either remove them or modify them to reference new_db_ptr before this function is called. Backpointers in entities referenced by old_db_ptr will be updated to point to new_db_ptr. The pointers old_db_ptr and new_db_ptr must be defined in the same model. The pointer old_db_ptr must not be locked when this function is called. Backpointers must be set correctly for old_db_ptr when this function is called.

Input

option

Options (not used)

old_db_ptr

The entity which is to be moved to new_db_ptr

new_db_ptr

A previously reserved database pointer

Return

MDA error code