VLink  2.0.0
A high-performance communication middleware
vlink::AbstractObject< FilterT > 模板类 参考

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

#include <abstract_factory.h>

类 vlink::AbstractObject< FilterT > 继承关系图:
vlink::AbstractObject< FilterT > 的协作图:

Public 类型

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

Public 成员函数

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

Protected 成员函数

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

详细描述

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().

模板参数
FilterTKey type used by the owning AbstractFactory for this object.

成员类型定义说明

◆ 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.

构造及析构函数说明

◆ AbstractObject()

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

◆ ~AbstractObject()

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

成员函数说明

◆ 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.

参数
implNon-owning peer pointer to track.
返回
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.

返回
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.

返回
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.

返回
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.

参数
implPointer to query.
返回
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.

返回
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.

参数
implPeer that owns callback.
callbackCallable void(const IntraData&) invoked for each in-process delivery.
返回
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.

参数
implPeer that owns callback.
callbackCallable void(const Bytes&) invoked for every received message.
返回
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.

参数
implPeer that owns callback.
callbackCallable invoked for every incoming RPC request.
返回
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.

参数
implPeer that owns callback.
callbackCallable void(bool) invoked when a remote client comes or goes.
返回
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.

参数
implPeer that owns callback.
callbackCallable invoked when the transport reports a status change.
返回
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.

参数
implPeer that owns callback.
callbackCallable void(bool) invoked when a subscriber appears or disappears.
返回
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.

参数
implPeer pointer previously passed to add_impl().
返回
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.

返回
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.

返回
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.

返回
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.

返回
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.

参数
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.

参数
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.

参数
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.

参数
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.

参数
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.

参数
callbackVisitor receiving each peer pointer and its stored handler.

该类的文档由以下文件生成: