Class DiscoveryManager

Class Documentation

class DiscoveryManager

Orchestrates entity discovery using pluggable strategies.

This class delegates discovery to strategy implementations based on the configured mode:

  • RUNTIME_ONLY: Uses RuntimeDiscoveryStrategy (traditional ROS graph)

  • MANIFEST_ONLY: Uses manifest as sole source of truth

  • HYBRID: Combines manifest definitions with runtime linking

The DiscoveryManager provides a unified interface for discovering:

  • Areas: Logical groupings (ROS 2 namespaces or manifest areas)

  • Components: Software/hardware units (ROS 2 nodes)

  • Apps: Software applications (manifest-defined)

  • Functions: Functional groupings (manifest-defined)

Public Functions

explicit DiscoveryManager(rclcpp::Node *node)

Construct the discovery manager.

Parameters:

node – ROS 2 node for graph introspection (must outlive this manager)

bool initialize(const DiscoveryConfig &config)

Initialize with configuration.

Loads manifest if configured, creates appropriate strategy. For RUNTIME_ONLY mode, this is a no-op.

Parameters:

config – Discovery configuration

Returns:

true if initialization succeeded

std::vector<Area> discover_areas()

Discover all areas.

Returns:

Vector of discovered Area entities

std::vector<Component> discover_components()

Discover all components.

Returns:

Vector of discovered Component entities

std::vector<App> discover_apps()

Discover all apps.

Returns:

Vector of discovered App entities (empty in runtime-only mode)

std::vector<Function> discover_functions()

Discover all functions.

Returns:

Vector of discovered Function entities (empty in runtime-only mode)

std::vector<Function> discover_functions(const std::vector<App> &apps)

Discover functions using pre-discovered apps.

Avoids redundant ROS 2 graph introspection when apps have already been discovered in the same refresh cycle. Falls back to the no-arg overload for modes that don’t support this optimization (manifest-only, hybrid).

Parameters:

apps – Pre-discovered apps (used only in RUNTIME_ONLY mode)

Returns:

Vector of discovered Function entities

std::optional<Area> get_area(const std::string &id)

Get area by ID.

Parameters:

idArea identifier

Returns:

Area if found

std::optional<Component> get_component(const std::string &id)

Get component by ID.

Parameters:

idComponent identifier

Returns:

Component if found

std::optional<App> get_app(const std::string &id)

Get app by ID.

Parameters:

idApp identifier

Returns:

App if found

std::optional<Function> get_function(const std::string &id)

Get function by ID.

Parameters:

idFunction identifier

Returns:

Function if found

std::vector<Area> get_subareas(const std::string &area_id)

Get subareas of an area.

Parameters:

area_id – Parent area ID

Returns:

Vector of child areas

std::vector<Component> get_subcomponents(const std::string &component_id)

Get subcomponents of a component.

Parameters:

component_id – Parent component ID

Returns:

Vector of child components

std::vector<Component> get_components_for_area(const std::string &area_id)

Get components in an area.

Parameters:

area_idArea ID

Returns:

Vector of components in the area

std::vector<App> get_apps_for_component(const std::string &component_id)

Get apps for a component.

Parameters:

component_idComponent ID

Returns:

Vector of apps associated with the component

std::vector<std::string> get_hosts_for_function(const std::string &function_id)

Get host component IDs for a function.

Parameters:

function_idFunction ID

Returns:

Vector of component IDs that host the function

std::vector<ServiceInfo> discover_services()

Discover all services in the system.

Returns:

Vector of ServiceInfo with schema information

std::vector<ActionInfo> discover_actions()

Discover all actions in the system.

Returns:

Vector of ActionInfo with schema information

std::optional<ServiceInfo> find_service(const std::string &component_ns, const std::string &operation_name) const

Find a service by component namespace and operation name.

Parameters:
  • component_nsComponent namespace

  • operation_name – Service name

Returns:

ServiceInfo if found, nullopt otherwise

std::optional<ActionInfo> find_action(const std::string &component_ns, const std::string &operation_name) const

Find an action by component namespace and operation name.

Parameters:
  • component_nsComponent namespace

  • operation_name – Action name

Returns:

ActionInfo if found, nullopt otherwise

void set_topic_sampler(NativeTopicSampler *sampler)

Set the topic sampler for component-topic mapping.

Parameters:

sampler – Pointer to NativeTopicSampler (must outlive DiscoveryManager)

void set_type_introspection(TypeIntrospection *introspection)

Set the type introspection for operation schema enrichment.

Parameters:

introspection – Pointer to TypeIntrospection (must outlive DiscoveryManager)

void refresh_topic_map()

Refresh the cached topic map.

bool is_topic_map_ready() const

Check if topic map has been built at least once.

Returns:

true if topic map is ready, false if not yet built

void add_plugin_layer(const std::string &plugin_name, IntrospectionProvider *provider)

Add a plugin layer to the merge pipeline.

Wraps an IntrospectionProvider as a PluginLayer and adds it to the pipeline. Only works in HYBRID mode.

Parameters:
void refresh_pipeline()

Re-execute the merge pipeline (hybrid mode only)

Call after adding plugin layers to trigger a single pipeline refresh.

discovery::ManifestManager *get_manifest_manager()

Get the manifest manager.

Returns:

Pointer to manifest manager (nullptr if not using manifest)

bool has_host_info_provider() const

Check if a host info provider is active.

Returns:

true if default component is enabled and provider exists

std::optional<Component> get_default_component() const

Get the default Component from HostInfoProvider.

Returns:

Component entity representing the local host, or nullopt if not enabled

inline DiscoveryMode get_mode() const

Get current discovery mode.

Returns:

Active discovery mode

std::string get_strategy_name() const

Get the current discovery strategy name.

Returns:

Strategy name (e.g., “runtime”, “manifest”, “hybrid”)

std::optional<discovery::MergeReport> get_merge_report() const

Get the last merge pipeline report (hybrid mode only)

Returns:

MergeReport if in hybrid mode, nullopt otherwise

std::optional<discovery::LinkingResult> get_linking_result() const

Get the last linking result (hybrid mode only)

Returns:

LinkingResult if in hybrid mode, nullopt otherwise