VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::AbstractFactory< FilterT > 模板类 参考

Topic-keyed factory that creates and caches AbstractObject instances. 更多...

#include <abstract_factory.h>

vlink::AbstractFactory< FilterT > 的协作图:

Public 成员函数

bool has_object (Object *ptr) const
 Returns true if ptr is a live object tracked by this factory.
template<typename ObjectT>
std::shared_ptr< ObjectT > get_object (const FilterT &filter)
 Retrieves or creates the AbstractObject for the given filter key.

Protected 成员函数

 AbstractFactory ()
 Protected default constructor.
virtual ~AbstractFactory ()
 Protected virtual destructor.

详细描述

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

Topic-keyed factory that creates and caches AbstractObject instances.

Maintains a std::map<FilterT, std::weak_ptr<Object>> so that multiple NodeImpl instances sharing the same topic key reuse the same AbstractObject. Objects are reference-counted: the entry is automatically removed from the map when the last shared_ptr to the object is destroyed, preventing stale entries from accumulating.

注解
This class is not copy-constructible or copy-assignable.
模板参数
FilterTThe key type used to identify topics (e.g. std::string).

构造及析构函数说明

◆ AbstractFactory()

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

Protected default constructor.

这是这个函数的调用关系图:

◆ ~AbstractFactory()

template<typename FilterT>
vlink::AbstractFactory< FilterT >::~AbstractFactory ( )
inlineprotectedvirtualdefault

Protected virtual destructor.

函数调用图:

成员函数说明

◆ get_object()

template<typename FilterT>
template<typename ObjectT>
std::shared_ptr< ObjectT > vlink::AbstractFactory< FilterT >::get_object ( const FilterT & filter)
inlinenodiscard

Retrieves or creates the AbstractObject for the given filter key.

If an object already exists for filter and is still alive (the weak_ptr is valid), the existing shared_ptr is returned. Otherwise a new ObjectT is heap-allocated, wrapped in a shared_ptr with a custom deleter that removes the entry from the internal map on destruction, and cached.

模板参数
ObjectTConcrete subclass of AbstractObject<FilterT> to instantiate.
参数
filterTopic key used to look up or create the object.
返回
A shared_ptr<ObjectT> for the given filter.

◆ has_object()

template<typename FilterT>
bool vlink::AbstractFactory< FilterT >::has_object ( Object * ptr) const
inlinenodiscard

Returns true if ptr is a live object tracked by this factory.

Checks the internal set of raw pointers to verify that ptr points to an object that was created by this factory and has not yet been destroyed.

参数
ptrRaw pointer to check.
返回
true if the object is currently alive; false otherwise.

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