This example introduces the MDL Discovery Api that helps to overview the MDL includes.
The mi::neuraylib::IMdl_discovery_api eases the discovery of available MDL modules by providing a graph view on all MDL packages and modules that can be found in the currently installed search paths.
In this example we will show how to use the mi::neuraylib::IMdl_discovery_api and how to traverse the resulting graph structure provided as mi::neuraylib::IMdl_discovery_result. As a first step we register the MDL search paths by calling the function configure()
, where all paths given on the command line are added to the MDL compiler by using the method add_module_path()
. The next step is to retrieve a pointer to the mi::neuraylib::IMdl_discovery_api interface and call the method discover()
. As a result a mi::neuraylib::IMdl_discovery_result will be returned, which contains a pointer to the discovered MDL graph structure. An example how to traverse this MDL graph structure is shown in the function log_api_package()
. The given data structure is a simple directed graph consisting of nodes representing MDL packages and modules. Starting from the root node, the recursive function log_api_package()
traverses through of the graph and interprets each node, depending of the given mi::neuraylib::IMdl_info::Kind type. If a mi::neuraylib::IMdl_package_info kind is found, that has been declared in multiple search paths, all these paths are listed to the log output. If a mi::neuraylib::IMdl_module_info is found, that shadows modules from other search paths, this is indicated in the log output as well.
This information makes it easier to overview the interaction of modules and packages from various sources no matter if they have been discovered a from file systems or from an archive.
Source Code Location: examples/mdl_sdk/example_discovery.cpp