Enumerating a provider's root namespace

Updated: April 19, 2023

After selecting a provider, applications can explore its root namespace to learn what data can be exchanged through this provider.

In the following example, a client program uses the PiPS API to access the root namespace for a provider, and to then enumerate the namespace by examining each entity and seeing whether it's a sub-namespace or a topic:
pips_entity_t* entity = NULL ;
pips_namespace_t* root = pips_provider_root( provider ) ;

/* Enumerate the entities in the root namespace. */
while ( (entity = pips_namespace_next_child( root, entity )) ) {
    if ( pips_topic_narrow( entity ) ) {
        printf( "Topic: %s\n", entity->name ) ;
    }
    else if ( pips_namespace_narrow( entity ) ) {
        printf( "Namespace: %s\n", entity->name ) ;
    }
    else {
        printf( "Unknown Entity Type: %s\n", entity->name ) ;
    }
}

Usually, your application would do something other than merely printing the entity names. The above code would be useful to display the contents of a namespace to a user; for example, if they wanted to see whether a provider's root namespace contains sub-namespaces or certain topics.