libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Topic::Domain Class Reference

主题域(Domain)管理器,用于组织多个主题。Domain manager for organizing multiple topics. More...

#include <message.hpp>

Collaboration diagram for LibXR::Topic::Domain:

Public Member Functions

 Domain (const char *name)
 构造函数,初始化或查找指定名称的主题域。Constructor initializing or looking up a domain by name.
 

Data Fields

RBTree< uint32_t >::Node< RBTree< uint32_t > > * node_
 指向该域的根节点。Pointer to the root node of the domain.
 

Detailed Description

主题域(Domain)管理器,用于组织多个主题。Domain manager for organizing multiple topics.

Definition at line 132 of file message.hpp.

Constructor & Destructor Documentation

◆ Domain()

LibXR::Topic::Domain::Domain ( const char name)
inline

构造函数,初始化或查找指定名称的主题域。Constructor initializing or looking up a domain by name.

Parameters
name主题域的名称。Name of the domain.

Definition at line 140 of file message.hpp.

141 {
142 if (!domain_)
143 {
145 if (!domain_)
146 {
147 domain_ =
148 new RBTree<uint32_t>([](const uint32_t &a, const uint32_t &b)
149 { return static_cast<int>(a) - static_cast<int>(b); });
150 }
152 }
153
154 auto crc32 = CRC32::Calculate(name, strlen(name));
155
156 auto domain = domain_->Search<RBTree<uint32_t>>(crc32);
157
158 if (domain != nullptr)
159 {
160 node_ = domain;
161 return;
162 }
163
165 [](const uint32_t &a, const uint32_t &b)
166 { return static_cast<int>(a) - static_cast<int>(b); });
167
168 domain_->Insert(*node_, crc32);
169 }
static uint32_t Calculate(const void *raw, size_t len)
计算数据的 CRC32 校验码 / Computes the CRC32 checksum for the given data
Definition crc.hpp:251
红黑树的泛型数据节点,继承自 BaseNode (Generic data node for Red-Black Tree, inheriting from BaseNode).
Definition rbt.hpp:64
红黑树实现,支持泛型键和值,并提供线程安全操作 (Red-Black Tree implementation supporting generic keys and values with thread...
Definition rbt.hpp:24
Node< Data > * Search(const Key &key)
搜索红黑树中的节点 (Search for a node in the Red-Black Tree).
Definition rbt.hpp:122
void Insert(BaseNode &node, KeyType &&key)
在树中插入新节点 (Insert a new node into the tree).
Definition rbt.hpp:237
void Lock() noexcept
阻塞直到获取锁 / Blocks until the lock is acquired
Definition spin_lock.hpp:44
void Unlock() noexcept
释放锁 / Releases the lock
Definition spin_lock.hpp:57
RBTree< uint32_t >::Node< RBTree< uint32_t > > * node_
指向该域的根节点。Pointer to the root node of the domain.
Definition message.hpp:174
static SpinLock domain_lock_
主题域访问的自旋锁,确保多线程安全 SpinLock for domain access to ensure thread safety
Definition message.hpp:1125
static RBTree< uint32_t > * domain_
主题域的红黑树结构,存储不同的主题 Red-Black Tree structure for storing different topics in the domain
Definition message.hpp:1119
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Field Documentation

◆ node_

RBTree<uint32_t>::Node<RBTree<uint32_t> >* LibXR::Topic::Domain::node_

指向该域的根节点。Pointer to the root node of the domain.

Definition at line 174 of file message.hpp.


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