VLink  2.0.0
A high-performance communication middleware
vlink::AbstractObject< FilterT > Class Template Reference

Topic-scoped fan-out store of NodeImpl peers and their callbacks. More...

#include <abstract_factory.h>

Inheritance diagram for vlink::AbstractObject< FilterT >:
Collaboration diagram for vlink::AbstractObject< FilterT >:

Public Types

using ImplList = std::unordered_set< NodeImpl * >
 Set of currently registered NodeImpl peers. More...
 
using ConnectCallbackMap = std::unordered_map< NodeImpl *, NodeImpl::ConnectCallback >
 Connect handlers per impl. More...
 
using ReqRespCallbackMap = std::unordered_map< NodeImpl *, NodeImpl::ReqRespCallback >
 Req/resp callbacks, keyed by impl. More...
 
using MsgCallbackMap = std::unordered_map< NodeImpl *, NodeImpl::MsgCallback >
 Message callbacks, keyed by impl. More...
 
using IntraMsgCallbackMap = std::unordered_map< NodeImpl *, NodeImpl::IntraMsgCallback >
 Intra-message callbacks. More...
 
using StatusCallbackMap = std::unordered_map< NodeImpl *, NodeImpl::StatusCallback >
 Status callbacks per impl. More...
 
using FindConnectCallback = Function< void(NodeImpl *, const NodeImpl::ConnectCallback &)>
 Visitor invoked for each connect entry. More...
 
using FindReqRespCallback = Function< void(NodeImpl *, const NodeImpl::ReqRespCallback &)>
 Visitor invoked for each req/resp entry. More...
 
using FindMsgCallback = Function< void(NodeImpl *, const NodeImpl::MsgCallback &)>
 Visitor invoked for each message entry. More...
 
using FindIntraMsgCallback = Function< void(NodeImpl *, const NodeImpl::IntraMsgCallback &)>
 Visitor for each intra-message entry. More...
 
using FindStatusCallback = Function< void(NodeImpl *, const NodeImpl::StatusCallback &)>
 Visitor invoked for each status entry. More...
 

Public Member Functions

bool add_impl (NodeImpl *impl)
 Registers impl as an active peer on this topic. More...
 
bool remove_impl (NodeImpl *impl)
 Removes impl from the peer set and forgets every associated callback. More...
 
NodeImplget_first_impl () const
 Returns the most recently registered peer. More...
 
bool is_contains_impl (NodeImpl *impl) const
 Tests whether impl is currently part of the peer set. More...
 
bool has_impl () const
 Indicates whether at least one peer has been registered. More...
 
bool register_server_connect_callback (NodeImpl *impl, NodeImpl::ConnectCallback &&callback)
 Stores callback as the server-side connect handler for impl. More...
 
bool register_sub_connect_callback (NodeImpl *impl, NodeImpl::ConnectCallback &&callback)
 Stores callback as the subscriber-side connect handler for impl. More...
 
bool register_req_resp_callback (NodeImpl *impl, NodeImpl::ReqRespCallback &&callback)
 Stores callback as the request/response handler for impl. More...
 
bool register_msg_callback (NodeImpl *impl, NodeImpl::MsgCallback &&callback)
 Stores callback as the serialised-message handler for impl. More...
 
bool register_intra_msg_callback (NodeImpl *impl, NodeImpl::IntraMsgCallback &&callback)
 Stores callback as the intra-process message handler for impl. More...
 
bool register_status_callback (NodeImpl *impl, NodeImpl::StatusCallback &&callback)
 Stores callback as the transport-status handler for impl. More...
 
bool server_connect_map_is_empty () const
 Reports whether the server-connect dictionary is empty. More...
 
bool sub_connect_map_is_empty () const
 Reports whether the subscriber-connect dictionary is empty. More...
 
bool req_resp_map_is_empty () const
 Reports whether the request/response dictionary is empty. More...
 
bool msg_map_is_empty () const
 Reports whether the serialised-message dictionary is empty. More...
 
bool intra_msg_map_is_empty () const
 Reports whether the intra-process message dictionary is empty. More...
 
bool status_map_is_empty () const
 Reports whether the transport-status dictionary is empty. More...
 
void traverse_server_connect_callback (const FindConnectCallback &callback)
 Walks the server-connect dictionary and invokes callback for every entry. More...
 
void traverse_sub_connect_callback (const FindConnectCallback &callback)
 Walks the subscriber-connect dictionary and invokes callback for every entry. More...
 
void traverse_req_resp_callback (const FindReqRespCallback &callback)
 Walks the request/response dictionary and invokes callback for every entry. More...
 
void traverse_msg_callback (const FindMsgCallback &callback)
 Walks the serialised-message dictionary and invokes callback for every entry. More...
 
void traverse_intra_msg_callback (const FindIntraMsgCallback &callback)
 Walks the intra-process dictionary and invokes callback for every entry. More...
 
void traverse_status_callback (const FindStatusCallback &callback)
 Walks the transport-status dictionary and invokes callback for every entry. More...
 

Protected Member Functions

 AbstractObject ()
 
 ~AbstractObject () override
 
bool has_called () const
 
void ignore_called ()
 

Detailed Description

template<typename FilterT>
class vlink::AbstractObject< FilterT >

Topic-scoped fan-out store of NodeImpl peers and their callbacks.

Holds the active NodeImpl pointer set together with the six callback dictionaries documented at file scope and serialises mutation, traversal and accounting through a std::recursive_mutex. The traversal helpers honour the ignore_called() escape hatch so that individual callbacks can opt out of the "any callback was invoked" accounting tracked by has_called().

Template Parameters
FilterTKey type used by the owning AbstractFactory for this object.

Member Typedef Documentation

◆ ConnectCallbackMap

template<typename FilterT >
using vlink::AbstractObject< FilterT >::ConnectCallbackMap = std::unordered_map<NodeImpl*, NodeImpl::ConnectCallback>

Connect handlers per impl.

◆ FindConnectCallback

template<typename FilterT >
using vlink::AbstractObject< FilterT >::FindConnectCallback = Function<void(NodeImpl*, const NodeImpl::ConnectCallback&)>

Visitor invoked for each connect entry.

◆ FindIntraMsgCallback

template<typename FilterT >
using vlink::AbstractObject< FilterT >::FindIntraMsgCallback = Function<void(NodeImpl*, const NodeImpl::IntraMsgCallback&)>

Visitor for each intra-message entry.

◆ FindMsgCallback

template<typename FilterT >
using vlink::AbstractObject< FilterT >::FindMsgCallback = Function<void(NodeImpl*, const NodeImpl::MsgCallback&)>

Visitor invoked for each message entry.

◆ FindReqRespCallback

template<typename FilterT >
using vlink::AbstractObject< FilterT >::FindReqRespCallback = Function<void(NodeImpl*, const NodeImpl::ReqRespCallback&)>

Visitor invoked for each req/resp entry.

◆ FindStatusCallback

template<typename FilterT >
using vlink::AbstractObject< FilterT >::FindStatusCallback = Function<void(NodeImpl*, const NodeImpl::StatusCallback&)>

Visitor invoked for each status entry.

◆ ImplList

template<typename FilterT >
using vlink::AbstractObject< FilterT >::ImplList = std::unordered_set<NodeImpl*>

Set of currently registered NodeImpl peers.

◆ IntraMsgCallbackMap

template<typename FilterT >
using vlink::AbstractObject< FilterT >::IntraMsgCallbackMap = std::unordered_map<NodeImpl*, NodeImpl::IntraMsgCallback>

Intra-message callbacks.

◆ MsgCallbackMap

template<typename FilterT >
using vlink::AbstractObject< FilterT >::MsgCallbackMap = std::unordered_map<NodeImpl*, NodeImpl::MsgCallback>

Message callbacks, keyed by impl.

◆ ReqRespCallbackMap

template<typename FilterT >
using vlink::AbstractObject< FilterT >::ReqRespCallbackMap = std::unordered_map<NodeImpl*, NodeImpl::ReqRespCallback>

Req/resp callbacks, keyed by impl.

◆ StatusCallbackMap

template<typename FilterT >
using vlink::AbstractObject< FilterT >::StatusCallbackMap = std::unordered_map<NodeImpl*, NodeImpl::StatusCallback>

Status callbacks per impl.

Constructor & Destructor Documentation

◆ AbstractObject()

template<typename FilterT >
vlink::AbstractObject< FilterT >::AbstractObject ( )
inlineprotecteddefault

◆ ~AbstractObject()

template<typename FilterT >
vlink::AbstractObject< FilterT >::~AbstractObject ( )
inlineoverrideprotecteddefault

Member Function Documentation

◆ add_impl()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::add_impl ( NodeImpl impl)
inline

Registers impl as an active peer on this topic.

Details.

Inserts impl into impl_list_ and refreshes the cached first_impl_ pointer to the latest registrant. The operation is serialised against all other public methods.

Parameters
implNon-owning peer pointer to track.
Returns
true when the pointer was newly inserted; false when it was already present.

◆ get_first_impl()

template<typename FilterT >
NodeImpl * vlink::AbstractObject< FilterT >::get_first_impl

Returns the most recently registered peer.

The "first" pointer follows the latest successful add_impl() call. After a matching remove_impl() the cache is repopulated with an arbitrary remaining peer, or nullptr if the set has been drained.

Returns
Pointer to the current cached peer; nullptr when no peer is registered.

◆ has_called()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::has_called
inlineprotected

◆ has_impl()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::has_impl
inline

Indicates whether at least one peer has been registered.

Returns
true when impl_list_ is non-empty.

◆ ignore_called()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::ignore_called
inlineprotected

◆ intra_msg_map_is_empty()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::intra_msg_map_is_empty
inline

Reports whether the intra-process message dictionary is empty.

Returns
true when no intra-message callbacks are registered.

◆ is_contains_impl()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::is_contains_impl ( NodeImpl impl) const
inline

Tests whether impl is currently part of the peer set.

Parameters
implPointer to query.
Returns
true when impl is registered, false otherwise.

◆ msg_map_is_empty()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::msg_map_is_empty
inline

Reports whether the serialised-message dictionary is empty.

Returns
true when no message callbacks are registered.

◆ register_intra_msg_callback()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::register_intra_msg_callback ( NodeImpl impl,
NodeImpl::IntraMsgCallback &&  callback 
)
inline

Stores callback as the intra-process message handler for impl.

Parameters
implPeer that owns callback.
callbackCallable void(const IntraData&) invoked for each in-process delivery.
Returns
true on insertion; false when already registered.

◆ register_msg_callback()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::register_msg_callback ( NodeImpl impl,
NodeImpl::MsgCallback &&  callback 
)
inline

Stores callback as the serialised-message handler for impl.

Parameters
implPeer that owns callback.
callbackCallable void(const Bytes&) invoked for every received message.
Returns
true on insertion; false when already registered.

◆ register_req_resp_callback()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::register_req_resp_callback ( NodeImpl impl,
NodeImpl::ReqRespCallback &&  callback 
)
inline

Stores callback as the request/response handler for impl.

Parameters
implPeer that owns callback.
callbackCallable invoked for every incoming RPC request.
Returns
true on insertion; false when already registered.

◆ register_server_connect_callback()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::register_server_connect_callback ( NodeImpl impl,
NodeImpl::ConnectCallback &&  callback 
)
inline

Stores callback as the server-side connect handler for impl.

Parameters
implPeer that owns callback.
callbackCallable void(bool) invoked when a remote client comes or goes.
Returns
true if the entry was inserted; false when one was already present.

◆ register_status_callback()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::register_status_callback ( NodeImpl impl,
NodeImpl::StatusCallback &&  callback 
)
inline

Stores callback as the transport-status handler for impl.

Parameters
implPeer that owns callback.
callbackCallable invoked when the transport reports a status change.
Returns
true on insertion; false when already registered.

◆ register_sub_connect_callback()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::register_sub_connect_callback ( NodeImpl impl,
NodeImpl::ConnectCallback &&  callback 
)
inline

Stores callback as the subscriber-side connect handler for impl.

Parameters
implPeer that owns callback.
callbackCallable void(bool) invoked when a subscriber appears or disappears.
Returns
true if the entry was inserted; false when one was already present.

◆ remove_impl()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::remove_impl ( NodeImpl impl)
inline

Removes impl from the peer set and forgets every associated callback.

Erases the pointer from impl_list_, reassigns first_impl_ if needed and drops the entry from all six callback dictionaries. Thread-safe.

Parameters
implPeer pointer previously passed to add_impl().
Returns
true if impl was found and removed; false otherwise.

◆ req_resp_map_is_empty()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::req_resp_map_is_empty
inline

Reports whether the request/response dictionary is empty.

Returns
true when no req/resp callbacks are registered.

◆ server_connect_map_is_empty()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::server_connect_map_is_empty
inline

Reports whether the server-connect dictionary is empty.

Returns
true when no server-connect callbacks are registered.

◆ status_map_is_empty()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::status_map_is_empty
inline

Reports whether the transport-status dictionary is empty.

Returns
true when no status callbacks are registered.

◆ sub_connect_map_is_empty()

template<typename FilterT >
bool vlink::AbstractObject< FilterT >::sub_connect_map_is_empty
inline

Reports whether the subscriber-connect dictionary is empty.

Returns
true when no subscriber-connect callbacks are registered.

◆ traverse_intra_msg_callback()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::traverse_intra_msg_callback ( const FindIntraMsgCallback callback)
inline

Walks the intra-process dictionary and invokes callback for every entry.

Parameters
callbackVisitor receiving each peer pointer and its stored handler.

◆ traverse_msg_callback()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::traverse_msg_callback ( const FindMsgCallback callback)
inline

Walks the serialised-message dictionary and invokes callback for every entry.

Parameters
callbackVisitor receiving each peer pointer and its stored handler.

◆ traverse_req_resp_callback()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::traverse_req_resp_callback ( const FindReqRespCallback callback)
inline

Walks the request/response dictionary and invokes callback for every entry.

Parameters
callbackVisitor receiving each peer pointer and its stored handler.

◆ traverse_server_connect_callback()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::traverse_server_connect_callback ( const FindConnectCallback callback)
inline

Walks the server-connect dictionary and invokes callback for every entry.

Iteration is performed while holding the recursive mutex. Individual visits may call ignore_called() to keep the current entry from setting the has_called() flag; iteration carries on regardless.

Parameters
callbackVisitor receiving each peer pointer and its stored handler.

◆ traverse_status_callback()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::traverse_status_callback ( const FindStatusCallback callback)
inline

Walks the transport-status dictionary and invokes callback for every entry.

Parameters
callbackVisitor receiving each peer pointer and its stored handler.

◆ traverse_sub_connect_callback()

template<typename FilterT >
void vlink::AbstractObject< FilterT >::traverse_sub_connect_callback ( const FindConnectCallback callback)
inline

Walks the subscriber-connect dictionary and invokes callback for every entry.

Parameters
callbackVisitor receiving each peer pointer and its stored handler.

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