cniCreateNodeContext

This function creates a context for an instance of a node object. It is called by the integration node whenever an instance of a node object is constructed. Nodes are constructed when a message flow is deployed by the integration node, or when the integration server is started.

The responsibilities of the node, when created, are to:
  1. (Optional) Verify that the name of the node specified in the nodeName parameter is supported by the factory.
  2. Allocate any node instance specific data areas that might be required (for example: context, attribute data, and terminals).
  3. Perform all additional resource acquisition or initialization that might be required for the processing of the node.
  4. Return the address of the context to the calling function. Whenever an implementation function for this node instance is called, the appropriate context is passed as an argument to that function. Therefore, a user-defined node developed in C does not have to maintain its own static pointers to per-instance data areas.
Defined In Type Member
CNI_VFT Mandatory iFpCreateNodeContext

Syntax

CciContext* cniCreateNodeContext(
  CciFactory*  factoryObject,
  CciChar*     nodeName,
  CciNode*     nodeObject);

Parameters

factoryObject
The address of the factory object that owns the node being created (input).
nodeName
The name of the node being created (input).
nodeObject
The address of the node object that has just been created (input).

Return values

If successful, the address of the node context is returned. Otherwise, a value of zero (CCI_NULL_ADDR) is returned.

Example

  static char* functionName = (char *)"_Switch_createNodeContext()";
  NODE_CONTEXT_ST* p;

  /* Allocate a pointer to the local context */
  p = (NODE_CONTEXT_ST *)malloc(sizeof(NODE_CONTEXT_ST));

  if (p) {

    /* Clear the context area */
    memset(p, 0, sizeof(NODE_CONTEXT_ST));

    /* Save our node object pointer in our context */
    p->nodeObject = nodeObject;

    /* Save our node name */
    CciCharNCpy((CciChar*) &p->nodeName, nodeName, MAX_NODE_NAME_LEN);
}
  else
	 /* Handle errors */