OpenClovis Logo

API Usage Examples

Code Examples.

Code Examples.

Code Example with comments:

// There are two default contexts there, either name can be registered
// under the existing contexts or the user can create their own context
// by following the following code snippet.
// global context, for local context CL_NS_USER_LOCAL
// any number other than CL_NS_DEFT_GLOBAL_MAP_COOKIE and
// CL_NS_DEFT_LOCAL_MAP_COOKIE as they meant for DEFAULT cookies.
ClUint32T contextMapCookie = 100;
ClUint32T contextId = 0;
// the returned context id will be used to register Names under that
// particular context
rc = clNameContextCreate(contextType, contextMapCookie, &contextId);
if( \c CL_OK != rc )
{
/* Error returned, take appropriate action */
}
// Register a name under the created context
ClNameSvcRegisterT regInfo = {0};
ClUint64T objRef = 0;
rc = clNameRegister(contextId, &regInfo, &objRef)
if( \c CL_OK != rc )
{
// Error returned, take appropriate action
}
// Given a name, getting the registered object reference from NameServer.
ClNameT name = {0}; // this should be filled with the specified name
ClNameSvcAttrEntryT attr = {0}; // attributes if any
ClUint32T contextMapCookie = 101; //context map cookie
rc = clNameToObjectReferenceGet(&name, 0, &attr, contextMapCookie,
&objRef);
if( \c CL_OK != rc )
{
// Error returned, take appropriate action
}
ClNameT name = {0}; // this should be filled with the specified name
ClNameSvcAttrEntryT attr = {0}; // attributes if any
ClUint32T contextMapCookie = 101; //context map cookie
ClNameSvcEntryPtrT outBuf = {0}; // this will be carrying mapping variable
rc = clNameToObjectMappingGet(&name, 0, &attr, ctxMapCookie, &outBuf);
if( \c CL_OK != rc )
{
// Error returned, take appropriate action
}
// Deregister all the names registered by particular component.
ClUint32T compId = YYY; // component id of the component.
if( \c CL_OK != rc )
{
// Error returned, take appropriate action
}
//Deregister a particular service
rc = clNameServiceDeregister(contextId, compId, &serviceName);
if( \c CL_OK != rc )
{
// Error returned, take appropriate action
}
// Delete the context while finalizing the system.
ClUint32T contextId = 0; // contextId of the contex to be created.
rc = clNameContextDelete(contextId);
if( CL_OK != rc )
{
//Error returned, take appropriate action
}
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
ClNameSvcContextT
Type of context to be created.
Definition: clNameApi.h:126
ClRcT clNameToObjectMappingGet(CL_IN ClNameT *pName, CL_IN ClUint32T attrCount, CL_IN ClNameSvcAttrEntryT *pAttr, CL_IN ClUint32T contextMapCookie, CL_OUT ClNameSvcEntryPtrT *pOutBuff)
Returns the entry of the service.
ClRcT clNameToObjectReferenceGet(CL_IN ClNameT *pName, CL_IN ClUint32T attrCount, CL_IN ClNameSvcAttrEntryT *pAttr, CL_IN ClUint32T contextMapCookie, CL_OUT ClUint64T *pObjReference)
Returns the object reference for a service.
ClRcT clNameServiceDeregister(CL_IN ClUint32T contextId, CL_IN ClUint32T compId, CL_IN ClNameT *serviceName)
De-registers a particular service provided by a component.
ClRcT clNameContextDelete(CL_IN ClUint32T contextId)
Deletes a context.
ClRcT clNameComponentDeregister(CL_IN ClUint32T compId)
De-registers all entries of a component with Name Service.
ClRcT clNameContextCreate(CL_IN ClNameSvcContextT contextType, CL_IN ClUint32T contextMapCookie, CL_OUT ClUint32T *contextId)
Creates a context.
ClRcT clNameRegister(CL_IN ClUint32T contextId, CL_IN ClNameSvcRegisterT *pNSRegisInfo, CL_INOUT ClUint64T *pObjReference)
Registers name to object reference mapping with Name Service.
@ CL_NS_USER_GLOBAL
User defined global context.
Definition: clNameApi.h:136
A name.
Definition: clCommon.h:197
Attribute structure.
Definition: clNameApi.h:231
The structure ClNameSvcRegisterT contains the name service registration information.
Definition: clNameApi.h:276
Name Service Entry.
Definition: clNameApi.h:351

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