#add: 完成基础的项目结构搭建

This commit is contained in:
2026-08-28 16:47:38 +08:00
commit 7bae861437
29 changed files with 434 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
idf_component_register(SRCS
"application.cc"
"context.cc"
"loader.cc"
INCLUDE_DIRS ".")
+45
View File
@@ -0,0 +1,45 @@
#include "application.hh"
#include <new> // For std::nothrow
#include <stop_token> // For std::stop_source, std::stop_token, std::nostopstate
#include <thread> // For std::jthread
#include "context.hh" // For context
#include "loader.hh" // For loader::ui, loader::service
class impl {
public:
impl()
: ui_thread_(&impl::ui_thread_function, this),
service_thread_(&impl::service_thread_function, this),
context_() {};
~impl() noexcept = default;
void run() {
context_.run();
}
private:
void ui_thread_function(std::stop_token token) {
// Implementation of the UI thread function
loader::ui ui_instance;
ui_instance.set_context(&context_);
}
void service_thread_function(std::stop_token token) {
// Implementation of the service thread function
loader::service service_instance;
service_instance.set_context(&context_);
}
private:
std::jthread ui_thread_;
std::jthread service_thread_;
context context_;
};
application::application() : pimpl_(new(std::nothrow) impl()) {}
application::~application() noexcept { delete pimpl_; }
void application::run() { pimpl_->run(); }
+18
View File
@@ -0,0 +1,18 @@
#ifndef APPLICATION_HH
#define APPLICATION_HH
#pragma once
class impl;
class application {
public:
application();
~application() noexcept;
void run();
private:
impl *pimpl_;
};
#endif // APPLICATION_HH
View File
+12
View File
@@ -0,0 +1,12 @@
#ifndef CONTEXT_HH
#define CONTEXT_HH
#pragma once
// 事件循环上下文
class context {
public:
context() = default;
~context() noexcept = default;
void run() noexcept;
};
#endif // CONTEXT_HH
View File
+25
View File
@@ -0,0 +1,25 @@
#ifndef LOADER_HH
#define LOADER_HH
#pragma once
class context;
namespace loader {
class ui {
public:
ui() = default;
~ui() noexcept = default;
void set_context(context *ctx);
};
class service {
public:
service() = default;
~service() noexcept = default;
void set_context(context *ctx);
};
} // namespace loader
#endif // LOADER_HH
@@ -0,0 +1 @@
idf_component_register()
@@ -0,0 +1 @@
idf_component_register()
+1
View File
@@ -0,0 +1 @@
idf_component_register()
+1
View File
@@ -0,0 +1 @@
idf_component_register()
@@ -0,0 +1,3 @@
idf_component_register(REQUIRES littlefs)
littlefs_create_partition_image(assets_fs "../../assets" FLASH_IN_PROJECT)
@@ -0,0 +1,3 @@
dependencies:
idf: ">=6.0.0,<6.1.0"
joltwallet/littlefs: "~=1.22.3"