OpenClovis Logo

API Usage Examples
Name Service

Code Examples. More...

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
}

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