OpenClovis Logo

API Usage Examples
Handle Management

Code Examples. More...

Code Examples.

The usage of handle library described as below. The handle database should be created for creating handles, this could be done by following API.

void hdlCallbackDestructor(void *pData)
{
/*
* this callback will get called for each handle destroy
* Handle data will be passed as part of the destroy callback.
*/
}

Creating the database as follows.

ClHandleT handle = CL_HANDLE_INVALID_VALUE;
ClXXXXDataT *pData = NULL;
rc = clHandleDatabaseCreate(hdlCallbackDestructor, &dbhandle);
if( CL_OK != rc )
{
/* do cleanup */
return rc;
}
/*Creating the handle from the database. */
rc = clHandleCreate(dbHandle, sizeof(ClXXXXDataT), &handle);
if( CL_OK != rc )
{
/* do cleanup */
return rc;
}
rc = clHandleCheckout(dbHandle, handle, (void **) &pData);
if( CL_OK != rc )
{
/* do cleanup */
return rc;
}
/* Use the pData */
pData->data = XXXX;
rc = clHandleCheckin(dbHandle, handle);
if( CL_OK != rc )
{
/* do cleanup */
return rc;
}
/* after the usage of handle, during the finalize, the allocated
handle can be deleted by the following apis
*/
rc = clHandleDestroy(dbHandle, handle);
if( CL_OK != rc )
{
/* do cleanup */
return rc;
}
/* everything is done with all the handles, the database should be
destroyed.
*/
if( CL_OK != rc )
{
return rc;
}

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