Adds/removes a single instance to/from an instance container identified by its container name and modelId. This function may also move an instance between containers. The behaviour is controlled by the values given in the source and target parameters <sourceContainerId> and < targetContainerId >. The table below illustrates this;
source |
target |
Behaviour |
Unset |
Set |
The instance will be inserted into the target container. |
Set |
Unset |
The instance will be removed from the source container. |
Set |
Set |
The instance will be moved from source to target. I.e removed from the source container and inserted into the target container. |
Related functions: edmiCreateInstanceContainer, edmiDeleteInstanceContainer, edmiDeleteInstanceContainerBN, edmiEmptyContainer, edmiEmptyContainerBN, edmiGetInstanceContainerId, edmiGetInstanceContainers, edmiSetContainerCheckedout, edmiSetContainerCheckedoutBN, edmiUnsetContainerCheckedout, edmiUnsetContainerCheckedoutBN, edmiInstanceToContainer, edmiInstancesToContainer, edmiInstancesToContainerBN.
Header:
#include "sdai.h"
Prototype
EdmiError edmiInstanceToContainerBN(SdaiModel modelId,
SdaiString sourceContainerName,
SdaiString targetContainerName,
SdaiAppInstance currInst);
Arguments:
modelId |
Instance Id that uniquely identifies the edmModel in the EDMdatabase |
sourceContainerName |
The name of the instance container from which to remove the instance <currInst>. By default, the instance will not be removed from any container. |
targetContainerName |
The name of the instance container in which to insert the instance <currInst>. By default, the instance will not be inserted into any container. |
currInst |
A numeric instanceID that uniquely identifies the instance of interest in the EDMdatabase. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : The EDMinterface is initialized.
Completion code != 0: The EDMinterface is not initialized. Completion code is an EDMinterface error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
EdmiError rstat;
int i;
SdaiModel modelId = 0;
SdaiInstance instId;
SdaiContainer contId = 0;
. . .
rstat = edmiCreateInstanceContainer(modelId, MODEL_CONTAINER,
"Contacts", "Johnnys contacts",
&contId);
rstat = edmiProtectInstance(contId, (PUBLIC_NONE |
GROUP_NONE | OWNER_WRITE));
instId = edmiCreateInstanceAndPutAttrsBN(modelId, "FRIEND", 3,
"FIRSTNAME", sdaiSTRING, "Lucy",
"LASTNAME", sdaiSTRING, "Grant",
"BIRTHDATE", sdaiSTRING, "01.13.1987");
/* Add lucy to contacts container */
if (rstat = edmiInstanceToContainerBN(modelId, NULL,
"Contacts", instId)) {
printf("\nError %d in edmiInstanceToContainerBN: %s", rstat,
edmiGetErrorText(rstat));
goto err;
}
. . .