libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
application.hpp
1#pragma once
2
3#include "libxr_def.hpp"
4#include "lockfree_list.hpp"
5
6namespace LibXR
7{
23{
24 public:
29 virtual void OnMonitor() = 0;
30
35 virtual ~Application() = default;
36};
37
43{
44 public:
46
57 {
58 auto node = new (std::align_val_t(LibXR::CACHE_LINE_SIZE))
60 app_list_.Add(*node);
61 }
62
72 {
74 [](Application* app)
75 {
76 app->OnMonitor();
77 return ErrorCode::OK;
78 });
79 }
80
87 size_t Size() { return app_list_.Size(); }
88};
89
90} // namespace LibXR
app_framework 的应用模块管理片段 Application-module management fragment of app_framework
virtual void OnMonitor()=0
周期性模块入口 Periodic module entry point
virtual ~Application()=default
虚析构函数 Virtual destructor
应用模块管理器
LibXR::LockFreeList app_list_
当前已注册模块链表 / List of currently registered modules.
void MonitorAll()
调用所有模块的 OnMonitor
void Register(Application &app)
注册一个应用模块
size_t Size()
获取模块数量
数据节点模板,继承自 BaseNode,用于存储具体数据类型。 Template data node that inherits from BaseNode to store specific data...
链表实现,用于存储和管理数据节点。 A linked list implementation for storing and managing data nodes.
ErrorCode Foreach(Func func)
遍历链表中的每个节点,并应用回调函数。 Iterates over each node in the list and applies a callback function.
void Add(BaseNode &data)
向链表添加一个节点。 Adds a node to the linked list.
uint32_t Size() noexcept
获取链表中的节点数量。 Gets the number of nodes in the linked list.
LibXR 命名空间
Definition ch32_can.hpp:14
@ OK
操作成功 | Operation successful
constexpr size_t CACHE_LINE_SIZE
缓存行大小 / Cache line size
Definition libxr_def.hpp:56