OpenClovis Logo

API Usage Examples

Code Examples.

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.
*/
rc = clHandleDatabaseDestroy(dbHandle)
if( CL_OK != rc )
{
return rc;
}
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
ClRcT clHandleDatabaseDestroy(CL_IN ClHandleDatabaseHandleT databaseHandle)
Destroys a handle database.
ClRcT clHandleDestroy(CL_IN ClHandleDatabaseHandleT databaseHandle, CL_IN ClHandleT handle)
Destroy a handle.
ClRcT clHandleDatabaseCreate(CL_IN void(*destructor)(void *), CL_OUT ClHandleDatabaseHandleT *databaseHandle)
Creates a handle database.
ClRcT clHandleCreate(CL_IN ClHandleDatabaseHandleT databaseHandle, CL_IN ClInt32T instanceSize, CL_OUT ClHandleT *handle)
Creates a handle.
ClRcT clHandleCheckout(CL_IN ClHandleDatabaseHandleT databaseHandle, CL_IN ClHandleT handle, CL_OUT void **instance)
Check out a handle.
ClRcT clHandleCheckin(CL_IN ClHandleDatabaseHandleT databaseHandle, CL_IN ClHandleT handle)
Check in a handle.
ClPtrT ClHandleDatabaseHandleT
Handle database handle.
Definition: clHandleApi.h:110
#define CL_HANDLE_INVALID_VALUE
Defines.
Definition: clHandleApi.h:95

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