VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
abstract_factory.h 文件参考

Topic-keyed factory and multi-implementation callback registry for VLink nodes. 更多...

#include <algorithm>
#include <atomic>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include "../base/logger.h"
#include "./node_impl.h"
abstract_factory.h 的引用(Include)关系图:

浏览该文件的源代码.

 Per-topic registry of NodeImpl instances and their associated callbacks. 更多...
 Topic-keyed factory that creates and caches AbstractObject instances. 更多...

命名空间

详细描述

Topic-keyed factory and multi-implementation callback registry for VLink nodes.

This header provides two cooperating templates used internally by every VLink node type (Publisher, Subscriber, Client, Server, Setter, Getter) to multiplex callbacks across multiple concurrent transport implementations sharing the same logical topic:

AbstractObject
A per-topic object that holds:
  • A set of active NodeImpl* instances registered on this topic.
  • Per-impl callback maps for all six callback types (server-connect, sub-connect, req/resp, msg, intra-msg, status).
  • Traversal helpers that iterate over all registered callbacks while holding a std::recursive_mutex, with early-exit support via ignore_called().
AbstractFactory
A map-based factory keyed on FilterT (typically std::string topic name) that creates and caches AbstractObject<FilterT> instances. Objects are stored as std::weak_ptr so they are automatically destroyed when no NodeImpl holds a reference.
Usage Model
// All Publisher<T> nodes on "dds://my_topic" share one AbstractObject:
auto obj = factory.get_object<MyObject>("dds://my_topic");
obj->add_impl(impl_ptr);
obj->register_msg_callback(impl_ptr, [](NodeImpl*, const MsgCallback& cb) {
cb(bytes);
});
// When a message arrives, dispatch to all registered impls:
obj->traverse_msg_callback([&](NodeImpl* impl, const MsgCallback& cb) {
cb(msg_data);
});
注解
All public methods on AbstractObject are thread-safe; they acquire the internal std::recursive_mutex before modifying or reading state.
模板参数
FilterTThe key type used to look up objects in the factory (e.g. std::string for topic URLs).