Adds/removes an aggregate or buffer of instances to/from an instance container identified by its container name and modelId. This function may also move instances 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 instances will be inserted into the target container. |
Set |
Unset |
The instances will be removed from the source container. |
Set |
Set |
The instances 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, edmiInstanceToContainerBN, edmiInstancesToContainer.
Header:
#include "sdai.h"
Prototype
EdmiError edmiInstancesToContainerBN(SdaiModel modelId,
SdaiString sourceContainerName,
SdaiString targetContainerName,
SdaiAggr instances,
SdaiAppInstance *instanceBuffer);
Arguments:
modelId |
Instance Id that uniquely identifies the edmModel in the EDMdatabase |
sourceContainerName |
The name of the instance container from which to remove the instances given in < instanceBuffer >. By default, no instances will be removed from any container. |
targetContainerName |
The name of the instance container in which to insert the instances given in <instanceBuffer>. By default, no instances will be inserted into any container. |
instances |
An aggregate containing all the instances to move to, from or between containers. If this parameter contains an aggregateId, the parameter <instanceBuffer> will be neglected. |
instanceBuffer |
An instance buffer containing all the instances to move to, from or between containers. |
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;
SdaiModel modelId = 0;
SdaiContainer oldContId, newContId;
SdaiPrimitiveType contType;
SdaiAggr instAggr;
. . .
/* Get contents of old container */
rstat = edmiGetInstanceContainerId(modelId, "OldContainer",
&contType, &oldContId,
&instAggr)
if (contType == LOCK_CONTAINER) {
/* Create new container */
rstat = edmiCreateInstanceContainer(modelId, MODEL_LOCK_CONTAINER,
"NewContainer", NULL,
&newContId);
/* Move contents to new container */
rstat = edmiInstancesToContainerBN(modelId, "OldContainer",
"NewContainer", instAggr, 0);
/* Delete old container */
rstat = edmiDeleteInstanceContainer(oldContId);
}
. . .