OpenClovis Logo

API Usage Examples

Code Examples.

Code Examples.

ClRcT rc = CL_OK;
// Queue should be created before using, creating the queue of 256
// elements
rc = clQueueCreate(256, clTstEnqCallback, clTstEnqCallback,
&queueHandle)),
if( \c CL_OK != rc )
{
// Queue create failed, nothing can be done, take appropriate action
}
// add a node to the queue.
ClQueueDataT qData = YYYY; // could be simple data or complex
rc = clQueueNodeInsert(queueHandle, qData);
if(\c CL_OK != rc)
{
// error occurred. Take appropriate action
}
//the first node will be deleted and the data will be returned on the
//data
rc = clQueueNodeDelete(queueHandle, &qData);
if( \c CL_OK != rc)
{
//Error occured. Take appropriate action.
}
ClUint32T size = 0;
// Getting the size of the Queue
rc = clQueueSizeGet(queueHandle, &size);
if( \c CL_OK != rc )
{
//Error occured. Take appropriate action.
}
//Queue should be deleted during finalize of system, otherwise it may
//lead to memory leaks, for each node deletion the QueueDestroyCallback
//will be called.
rc = clQueueDelete(queueHandle);
if(\c CL_OK != rc)
{
// Error occured. Take appropriate action.
}
// to walk through all the elements on the queue, the following
// operation should be performed.
// the queuewalk callback function is getting called while walking
//through all the queue elements.
void clTstQueueWalkCb(ClQueueT qData, void *pData)
{
// Data of the walk thru node.
// Cookie of the QueueWalk function.
}
rc = clQueueWalk(queueHandle, clTstQueueWalkCb, pCookie);
if( \c CL_OK != rc )
{
// Error occured. Take appropriate action.
}
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
#define CL_HANDLE_INVALID_VALUE
Defines.
Definition: clHandleApi.h:95
ClRcT clQueueWalk(CL_IN ClQueueT queueHandle, CL_IN ClQueueWalkCallbackT fpUserWalkFunction, CL_IN void *userArg)
Walks through the queue.
ClPtrT ClQueueT
The type of the handle for the queue.
Definition: clQueueApi.h:69
ClRcT clQueueNodeInsert(CL_IN ClQueueT queueHandle, CL_IN ClQueueDataT userData)
Enqueues an element (user-data) into the Queue.
ClRcT clQueueNodeDelete(CL_IN ClQueueT queueHandle, CL_OUT ClQueueDataT *userData)
Dequeues an element from the queue.
ClRcT clQueueDelete(CL_IN ClQueueT *pQueueHandle)
Destroys the queue.
ClRcT clQueueCreate(CL_IN ClUint32T maxSize, CL_IN ClQueueDequeueCallbackT fpUserDequeueCallBack, CL_IN ClQueueDequeueCallbackT fpUserDestroyCallBack, CL_OUT ClQueueT *pQueueHandle)
Creates a queue.
ClPtrT ClQueueDataT
The type of the handle for the user-data.
Definition: clQueueApi.h:79
ClRcT clQueueSizeGet(CL_IN ClQueueT queueHandle, CL_OUT ClUint32T *pSize)
Retrieves the number of data elements in the queue.

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen