VLink  2.0.0
A high-performance communication middleware
vlink::DiscoveryViewer Class Reference

MessageLoop-based aggregator of live VLink endpoint announcements. More...

#include <discovery_viewer.h>

Inheritance diagram for vlink::DiscoveryViewer:
Collaboration diagram for vlink::DiscoveryViewer:

Classes

struct  Info
 One row of the discovery snapshot, describing a URL and its publishers/subscribers. More...
 
struct  Process
 Identity of a process that hosts at least one endpoint for a URL. More...
 

Public Types

enum  FilterType : uint8_t { kFilterNone = 0 , kFilterAvailable = 1 , kFilterNative = 2 }
 Selects which announcements contribute to the live snapshot. More...
 
using Callback = Function< void(const std::vector< Info > &info_list)>
 Callback signature delivered whenever the snapshot changes. More...
 
 Internal queue implementation type. More...
 Back-pressure strategy applied when the bounded queue is at capacity. More...
 Built-in priority levels for kPriorityType loops; higher values dispatch first. More...

Public Member Functions

 DiscoveryViewer (FilterType type=kFilterNone)
 Builds the viewer with the requested filter mode. More...
 
 ~DiscoveryViewer () override
 Stops the viewer loop and releases resources. More...
 
void register_callback (Callback &&callback)
 Registers the callback notified on every snapshot change. More...
 
std::vector< Infoget_info_list ()
 Returns a copy of the live snapshot at the moment of the call. More...
 
std::string get_ser_type (const std::string &url) const
 Resolves the announced serialisation type for url. More...
 
SchemaType get_schema_type (const std::string &url) const
 Resolves the announced coarse schema family for url. More...
 

Static Public Member Functions

static ImplType convert_type (std::string_view str)
 Translates a discovery role token to the corresponding ImplType bit. More...
 
static std::string convert_type_to_view (uint32_t type)
 Formats an ImplType bitmask as a human-readable label. More...
 
static std::string convert_type_to_view (uint32_t type, const std::vector< Process > &process_list)
 Formats an ImplType bitmask together with its process list. More...
 
static std::string get_listen_address ()
 Returns the UDP multicast/broadcast address used by the discovery subsystem. More...
 

Protected Member Functions

size_t get_max_task_count () const override
 Returns the maximum queue depth. More...
 
uint32_t get_max_elapsed_time () const override
 Returns the maximum allowed task execution time in milliseconds. More...
 
void on_begin () override
 Hook invoked once on the loop thread before the first task runs. More...
 
void on_end () override
 Hook invoked once on the loop thread after the last task runs. More...
 

Detailed Description

MessageLoop-based aggregator of live VLink endpoint announcements.

Construct with the desired filter and start with async_run(). Each viewer is explicitly owned by the caller; no process-global viewer is exposed. The viewer continuously rebuilds an Info list and notifies the registered callback every time the topology changes.

Member Typedef Documentation

◆ Callback

using vlink::DiscoveryViewer::Callback = Function<void(const std::vector<Info>& info_list)>

Callback signature delivered whenever the snapshot changes.

Invoked on the viewer's MessageLoop thread with the freshly built list.

Member Enumeration Documentation

◆ FilterType

Selects which announcements contribute to the live snapshot.

Value Effect
kFilterNone All announcements visible
kFilterAvailable Drop remote announcements for local-only URL schemes
kFilterNative Keep only announcements from the same host
Enumerator
kFilterNone 

No filtering applied.

kFilterAvailable 

Drop remote announcements for local-only URL schemes.

kFilterNative 

Keep only same-host announcements.

Constructor & Destructor Documentation

◆ DiscoveryViewer()

vlink::DiscoveryViewer::DiscoveryViewer ( FilterType  type = kFilterNone)
explicit

Builds the viewer with the requested filter mode.

Parameters
typeFilter selecting which announcements survive (default: kFilterNone).

◆ ~DiscoveryViewer()

vlink::DiscoveryViewer::~DiscoveryViewer ( )
override

Stops the viewer loop and releases resources.

Member Function Documentation

◆ convert_type()

static ImplType vlink::DiscoveryViewer::convert_type ( std::string_view  str)
static

Translates a discovery role token to the corresponding ImplType bit.

Parameters
strRole token: "Ser", "Cli", "Pub", "Sub", "Set" or "Get".
Returns
Matching ImplType, or 0 when the token is not recognised.

◆ convert_type_to_view() [1/2]

static std::string vlink::DiscoveryViewer::convert_type_to_view ( uint32_t  type)
static

Formats an ImplType bitmask as a human-readable label.

Parameters
typeImplType bitmask.
Returns
Display string suitable for tooling output.

◆ convert_type_to_view() [2/2]

static std::string vlink::DiscoveryViewer::convert_type_to_view ( uint32_t  type,
const std::vector< Process > &  process_list 
)
static

Formats an ImplType bitmask together with its process list.

Parameters
typeImplType bitmask.
process_listProcesses to include in the display.
Returns
Combined display string.

◆ get_info_list()

std::vector<Info> vlink::DiscoveryViewer::get_info_list ( )

Returns a copy of the live snapshot at the moment of the call.

Returns
Vector of Info rows.

◆ get_listen_address()

static std::string vlink::DiscoveryViewer::get_listen_address ( )
static

Returns the UDP multicast/broadcast address used by the discovery subsystem.

◆ get_max_elapsed_time()

uint32_t vlink::DiscoveryViewer::get_max_elapsed_time ( ) const
overrideprotectedvirtual

Returns the maximum allowed task execution time in milliseconds.

Tasks exceeding this duration trigger on_task_timeout. Zero disables the check.

Returns
Maximum execution time in milliseconds.

Reimplemented from vlink::MessageLoop.

◆ get_max_task_count()

size_t vlink::DiscoveryViewer::get_max_task_count ( ) const
overrideprotectedvirtual

Returns the maximum queue depth.

Returns
kMaxTaskSize (10000) by default.

Reimplemented from vlink::MessageLoop.

◆ get_schema_type()

SchemaType vlink::DiscoveryViewer::get_schema_type ( const std::string &  url) const

Resolves the announced coarse schema family for url.

Parameters
urlTopic URL.
Returns
SchemaType, or SchemaType::kUnknown when unavailable.

◆ get_ser_type()

std::string vlink::DiscoveryViewer::get_ser_type ( const std::string &  url) const

Resolves the announced serialisation type for url.

Parameters
urlTopic URL.
Returns
Announced serialisation type, or an empty string when unknown.

◆ on_begin()

void vlink::DiscoveryViewer::on_begin ( )
overrideprotectedvirtual

Hook invoked once on the loop thread before the first task runs.

Subclasses override to perform per-thread initialisation.

Reimplemented from vlink::MessageLoop.

◆ on_end()

void vlink::DiscoveryViewer::on_end ( )
overrideprotectedvirtual

Hook invoked once on the loop thread after the last task runs.

Subclasses override to perform per-thread cleanup.

Reimplemented from vlink::MessageLoop.

◆ register_callback()

void vlink::DiscoveryViewer::register_callback ( Callback &&  callback)

Registers the callback notified on every snapshot change.

Replaces any previously installed callback; only the most recent registration remains effective.

Parameters
callbackFunction invoked with the new Info list.

The documentation for this class was generated from the following file: