VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
abstract_factory.h File Reference

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

#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"
Include dependency graph for abstract_factory.h:

Go to the source code of this file.

Classes

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

Namespaces

Detailed Description

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);
});
Note
All public methods on AbstractObject are thread-safe; they acquire the internal std::recursive_mutex before modifying or reading state.
Template Parameters
FilterTThe key type used to look up objects in the factory (e.g. std::string for topic URLs).