BS 0.1.0 File未完善
This commit is contained in:
@@ -74,60 +74,19 @@ namespace Convention
|
||||
}
|
||||
};
|
||||
|
||||
template<template<typename> class ElementPtr = std::shared_ptr>
|
||||
class DependenceModel
|
||||
: public IConvertModel<bool>
|
||||
{
|
||||
private:
|
||||
std::vector<ElementPtr<IConvertable<bool>>> queries;
|
||||
std::vector<IConvertable<bool>*> queries;
|
||||
public:
|
||||
DependenceModel(std::vector<ElementPtr<IConvertable<bool>>> queries) :__init(queries) {}
|
||||
DependenceModel(std::vector<IConvertable<bool>*> queries) :__init(queries) {}
|
||||
|
||||
bool ConvertTo()
|
||||
{
|
||||
for (auto&& query : queries)
|
||||
{
|
||||
if ((*query).ConvertTo() == false)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
decltype(auto) begin() noexcept
|
||||
{
|
||||
return queries.begin();
|
||||
}
|
||||
|
||||
decltype(auto) end() noexcept
|
||||
{
|
||||
return queries.end();
|
||||
}
|
||||
|
||||
virtual void Load(std::string_view data) override
|
||||
{
|
||||
throw std::runtime_error("NotImplementedException");
|
||||
}
|
||||
|
||||
virtual string Save() override
|
||||
{
|
||||
throw std::runtime_error("NotImplementedException");
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class DependenceModel<ElementTuple>
|
||||
: public IConvertModel<bool>
|
||||
{
|
||||
private:
|
||||
std::vector<IConvertable<bool>> queries;
|
||||
public:
|
||||
DependenceModel(std::vector<IConvertable<bool>> queries) :__init(queries) {}
|
||||
|
||||
bool ConvertTo()
|
||||
{
|
||||
for (auto&& query : queries)
|
||||
{
|
||||
if (query.ConvertTo() == false)
|
||||
if (query->ConvertTo() == false)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -177,10 +136,13 @@ namespace Convention
|
||||
#pragma region Objects Registered
|
||||
|
||||
private:
|
||||
|
||||
std::map<TypeID, std::vector<std::shared_ptr<IConvertable<bool>>>> ImplTypeQuery;
|
||||
|
||||
std::set<TypeID> RegisterHistory;
|
||||
std::map<TypeID, void*> UncompleteTargets;
|
||||
std::map<TypeID, std::function<void()>> Completer;
|
||||
std::map<TypeID, DependenceModel<>> Dependences;
|
||||
std::map<TypeID, DependenceModel> Dependences;
|
||||
std::map<TypeID, void*> Childs;
|
||||
|
||||
class TypeQuery
|
||||
@@ -247,6 +209,7 @@ namespace Convention
|
||||
{
|
||||
Childs[complete] = UncompleteTargets[complete];
|
||||
UncompleteTargets.erase(complete);
|
||||
ImplTypeQuery.erase(complete);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,12 +223,14 @@ namespace Convention
|
||||
RegisterHistory.insert(slot.hash_code());
|
||||
Completer[slot.hash_code()] = completer;
|
||||
UncompleteTargets[slot.hash_code()] = target;
|
||||
std::vector<std::shared_ptr<IConvertable<bool>>> dependenceModel;
|
||||
std::vector<IConvertable<bool>*> dependenceModel;
|
||||
for (auto&& type : dependences)
|
||||
{
|
||||
dependenceModel.push_back(std::make_shared<TypeQuery>(new TypeQuery(slot)));
|
||||
auto cur = std::make_shared<TypeQuery>(new TypeQuery(slot));
|
||||
ImplTypeQuery[slot.hash_code()].push_back(cur);
|
||||
dependenceModel.push_back(cur.get());
|
||||
}
|
||||
Dependences[slot.hash_code()] = DependenceModel<>(dependenceModel);
|
||||
Dependences[slot.hash_code()] = DependenceModel(dependenceModel);
|
||||
std::set<TypeID> buffer;
|
||||
while (InternalRegisteringComplete(buffer))
|
||||
InternalRegisteringUpdate(buffer);
|
||||
@@ -320,11 +285,11 @@ namespace Convention
|
||||
|
||||
public:
|
||||
Listening(const std::function<void(const ISignal&)>& action, TypeID type)
|
||||
: __init(action),__init(type){ }
|
||||
: __init(action), __init(type) {}
|
||||
Listening(const std::function<void(const ISignal&)>& action, Type type)
|
||||
: __init(action), type(type.hash_code()) {}
|
||||
|
||||
void StopListening()
|
||||
void StopListening() const
|
||||
{
|
||||
if (SingletonModel<Architecture>::Instance().SignalListener.count(type))
|
||||
SingletonModel<Architecture>::Instance().SignalListener[type].erase(action);
|
||||
@@ -349,7 +314,7 @@ namespace Convention
|
||||
template<typename Signal>
|
||||
Listening AddListener(std::enable_if_t<std::is_base_of_v<ISignal, Signal>, std::function<void(const Signal&)>> listener)
|
||||
{
|
||||
return AddListener<Signal>(typeof(Signal), listener);
|
||||
return AddListener<Signal>(typeid(Signal), listener);
|
||||
}
|
||||
|
||||
void SendMessage(Type slot, const ISignal& signal)
|
||||
@@ -366,7 +331,7 @@ namespace Convention
|
||||
template<typename Signal>
|
||||
void SendMessage(std::enable_if_t<std::is_base_of_v<ISignal, Signal>, const Signal&> signal)
|
||||
{
|
||||
return SendMessage(signal.GetType(), signal);
|
||||
return SendMessage(typeid(Signal), signal);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@@ -8,43 +8,43 @@ namespace Convention
|
||||
{
|
||||
namespace Math
|
||||
{
|
||||
// Mathematical constants
|
||||
template<typename T>
|
||||
struct Constants
|
||||
{
|
||||
static constexpr T PI = static_cast<T>(3.14159265358979323846);
|
||||
static constexpr T E = static_cast<T>(2.71828182845904523536);
|
||||
static constexpr T SQRT2 = static_cast<T>(1.41421356237309504880);
|
||||
static constexpr T SQRT3 = static_cast<T>(1.73205080756887729353);
|
||||
static constexpr T LN2 = static_cast<T>(0.69314718055994530942);
|
||||
static constexpr T LN10 = static_cast<T>(2.30258509299404568402);
|
||||
};
|
||||
|
||||
// Basic math utilities
|
||||
template<typename T>
|
||||
constexpr T Abs(const T& value)
|
||||
inline T Abs(const T& value)
|
||||
{
|
||||
return value < T{} ? -value : value;
|
||||
return std::abs(value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T Min(const T& a, const T& b)
|
||||
inline T Min(const T& a, const T& b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
return std::min(a, b);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T Max(const T& a, const T& b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
template<typename T, typename... Args>
|
||||
inline T Min(const T& a, const Args&... args)
|
||||
{
|
||||
return std::min(a, Min<T>(args...));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T Clamp(const T& value, const T& min, const T& max)
|
||||
inline T Max(const T& a, const T& b)
|
||||
{
|
||||
return Min(Max(value, min), max);
|
||||
return std::max(a, b);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
inline T Max(const T& a, const Args&... args)
|
||||
{
|
||||
return std::max(a, Max<T>(args...));
|
||||
}
|
||||
|
||||
template<typename T,typename T2,typename T3>
|
||||
constexpr T Clamp(const T& value, const T2& min, const T3& max)
|
||||
{
|
||||
return Min<T>(Max<T>(value, min), max);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T Sign(const T& value)
|
||||
{
|
||||
@@ -117,13 +117,13 @@ namespace Convention
|
||||
template<typename T>
|
||||
constexpr T DegToRad(const T& degrees)
|
||||
{
|
||||
return degrees * Constants<T>::PI / static_cast<T>(180);
|
||||
return degrees * std::_Pi_val / static_cast<T>(180);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T RadToDeg(const T& radians)
|
||||
{
|
||||
return radians * static_cast<T>(180) / Constants<T>::PI;
|
||||
return radians * static_cast<T>(180) / std::_Pi_val;
|
||||
}
|
||||
|
||||
// Logarithmic functions
|
||||
|
@@ -3,377 +3,10 @@
|
||||
#define Convention_Runtime_Plugins_hpp
|
||||
|
||||
#include "Config.hpp"
|
||||
#include "Architecture.hpp"
|
||||
|
||||
namespace Convention
|
||||
{
|
||||
// Priority Queue implementation for plugin priorities
|
||||
template<typename T>
|
||||
class PriorityQueue
|
||||
{
|
||||
public:
|
||||
enum class Comparator
|
||||
{
|
||||
Less = -1,
|
||||
Equal = 0,
|
||||
Greater = 1
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<T> elements;
|
||||
std::function<int(const T&, const T&)> compare_func;
|
||||
Comparator comparator;
|
||||
|
||||
public:
|
||||
PriorityQueue(Comparator comp = Comparator::Less, size_t capacity = 1)
|
||||
: comparator(comp)
|
||||
{
|
||||
elements.reserve(std::max(capacity, size_t{1}));
|
||||
|
||||
compare_func = [comp](const T& a, const T& b) -> int {
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
int result = (a > b) - (a < b);
|
||||
return result * static_cast<int>(comp);
|
||||
} else {
|
||||
if (a < b) return -1 * static_cast<int>(comp);
|
||||
if (b < a) return 1 * static_cast<int>(comp);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename Compare>
|
||||
PriorityQueue(Compare comp, size_t capacity = 1)
|
||||
: compare_func(comp)
|
||||
{
|
||||
elements.reserve(std::max(capacity, size_t{1}));
|
||||
}
|
||||
|
||||
// Basic properties
|
||||
size_t Size() const { return elements.size(); }
|
||||
size_t Count() const { return Size(); }
|
||||
size_t Capacity() const { return elements.capacity(); }
|
||||
bool IsEmpty() const { return elements.empty(); }
|
||||
|
||||
const T& Top() const
|
||||
{
|
||||
if (IsEmpty()) throw std::runtime_error("Queue is empty");
|
||||
return elements[0];
|
||||
}
|
||||
|
||||
// Core operations
|
||||
void Enqueue(const T& value)
|
||||
{
|
||||
elements.push_back(value);
|
||||
ShiftUp(elements.size() - 1);
|
||||
}
|
||||
|
||||
void Enqueue(T&& value)
|
||||
{
|
||||
elements.push_back(std::move(value));
|
||||
ShiftUp(elements.size() - 1);
|
||||
}
|
||||
|
||||
T Dequeue()
|
||||
{
|
||||
if (IsEmpty()) throw std::runtime_error("Queue is empty");
|
||||
|
||||
T result = std::move(elements[0]);
|
||||
elements[0] = std::move(elements.back());
|
||||
elements.pop_back();
|
||||
|
||||
if (!IsEmpty()) {
|
||||
ShiftDown(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TryDequeue(T& result)
|
||||
{
|
||||
if (IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
result = Dequeue();
|
||||
return true;
|
||||
}
|
||||
|
||||
const T& Peek() const
|
||||
{
|
||||
return Top();
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
bool Contains(const T& item) const
|
||||
{
|
||||
return std::find(elements.begin(), elements.end(), item) != elements.end();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
elements.clear();
|
||||
}
|
||||
|
||||
std::vector<T> ToArray() const
|
||||
{
|
||||
return elements;
|
||||
}
|
||||
|
||||
void TrimExcess()
|
||||
{
|
||||
if (elements.size() < elements.capacity() * 0.9) {
|
||||
elements.shrink_to_fit();
|
||||
}
|
||||
}
|
||||
|
||||
void EnsureCapacity(size_t minCapacity)
|
||||
{
|
||||
if (elements.capacity() < minCapacity) {
|
||||
elements.reserve(minCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void ShiftUp(size_t index)
|
||||
{
|
||||
while (index > 0) {
|
||||
size_t parent = (index - 1) / 2;
|
||||
if (compare_func(elements[index], elements[parent]) >= 0) break;
|
||||
|
||||
std::swap(elements[index], elements[parent]);
|
||||
index = parent;
|
||||
}
|
||||
}
|
||||
|
||||
void ShiftDown(size_t index)
|
||||
{
|
||||
size_t size = elements.size();
|
||||
while (true) {
|
||||
size_t left = 2 * index + 1;
|
||||
size_t right = 2 * index + 2;
|
||||
size_t smallest = index;
|
||||
|
||||
if (left < size && compare_func(elements[left], elements[smallest]) < 0) {
|
||||
smallest = left;
|
||||
}
|
||||
if (right < size && compare_func(elements[right], elements[smallest]) < 0) {
|
||||
smallest = right;
|
||||
}
|
||||
|
||||
if (smallest == index) break;
|
||||
|
||||
std::swap(elements[index], elements[smallest]);
|
||||
index = smallest;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Plugin base interface
|
||||
class IPlugin
|
||||
{
|
||||
public:
|
||||
virtual ~IPlugin() = default;
|
||||
virtual std::string GetName() const = 0;
|
||||
virtual std::string GetVersion() const = 0;
|
||||
virtual bool Initialize() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual int GetPriority() const { return 0; }
|
||||
};
|
||||
|
||||
// Plugin information
|
||||
struct PluginInfo
|
||||
{
|
||||
std::string name;
|
||||
std::string version;
|
||||
std::string description;
|
||||
std::vector<std::string> dependencies;
|
||||
int priority = 0;
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
// Plugin manager interface
|
||||
class PluginManager
|
||||
{
|
||||
public:
|
||||
static PluginManager& GetInstance()
|
||||
{
|
||||
static PluginManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Plugin registration (interface only)
|
||||
template<typename T>
|
||||
bool RegisterPlugin()
|
||||
{
|
||||
static_assert(std::is_base_of_v<IPlugin, T>, "T must inherit from IPlugin");
|
||||
|
||||
// TODO: Implement plugin registration
|
||||
// This would typically involve:
|
||||
// 1. Creating instance of T
|
||||
// 2. Calling Initialize()
|
||||
// 3. Adding to plugin registry
|
||||
// 4. Managing dependencies
|
||||
|
||||
throw std::runtime_error("Plugin system implementation required");
|
||||
}
|
||||
|
||||
bool LoadPlugin(const std::string& pluginPath)
|
||||
{
|
||||
// TODO: Implement dynamic plugin loading
|
||||
// This would typically involve:
|
||||
// 1. Loading shared library (.dll/.so/.dylib)
|
||||
// 2. Finding plugin entry point
|
||||
// 3. Creating plugin instance
|
||||
// 4. Registering plugin
|
||||
|
||||
throw std::runtime_error("Dynamic plugin loading implementation required");
|
||||
}
|
||||
|
||||
bool UnloadPlugin(const std::string& pluginName)
|
||||
{
|
||||
// TODO: Implement plugin unloading
|
||||
throw std::runtime_error("Plugin unloading implementation required");
|
||||
}
|
||||
|
||||
std::vector<PluginInfo> GetLoadedPlugins() const
|
||||
{
|
||||
// TODO: Return list of loaded plugins
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* GetPlugin(const std::string& name) const
|
||||
{
|
||||
// TODO: Find plugin by name and cast to type T
|
||||
throw std::runtime_error("Plugin retrieval implementation required");
|
||||
}
|
||||
|
||||
bool IsPluginLoaded(const std::string& name) const
|
||||
{
|
||||
// TODO: Check if plugin is loaded
|
||||
return false;
|
||||
}
|
||||
|
||||
void EnablePlugin(const std::string& name)
|
||||
{
|
||||
// TODO: Enable plugin
|
||||
}
|
||||
|
||||
void DisablePlugin(const std::string& name)
|
||||
{
|
||||
// TODO: Disable plugin
|
||||
}
|
||||
|
||||
// Plugin discovery
|
||||
std::vector<std::string> DiscoverPlugins(const std::string& directory) const
|
||||
{
|
||||
// TODO: Scan directory for plugin files
|
||||
throw std::runtime_error("Plugin discovery implementation required");
|
||||
}
|
||||
|
||||
// Event system integration
|
||||
template<typename EventType>
|
||||
void BroadcastEvent(const EventType& event)
|
||||
{
|
||||
// TODO: Send event to all registered plugins
|
||||
// Integration with Architecture's event system
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<std::string, std::shared_ptr<IPlugin>> loaded_plugins;
|
||||
std::map<std::string, PluginInfo> plugin_info;
|
||||
PriorityQueue<std::shared_ptr<IPlugin>> priority_queue;
|
||||
|
||||
PluginManager() = default;
|
||||
};
|
||||
|
||||
// Platform-specific plugin utilities
|
||||
namespace Platform
|
||||
{
|
||||
// Windows-specific functionality (interface only)
|
||||
class WindowsPlugin : public IPlugin
|
||||
{
|
||||
public:
|
||||
std::string GetName() const override { return "WindowsPlugin"; }
|
||||
std::string GetVersion() const override { return "1.0.0"; }
|
||||
|
||||
bool Initialize() override
|
||||
{
|
||||
// TODO: Initialize Windows-specific features
|
||||
return true;
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
// TODO: Cleanup Windows-specific resources
|
||||
}
|
||||
|
||||
// Windows-specific methods (interface only)
|
||||
bool ShowMessageBox(const std::string& title, const std::string& message)
|
||||
{
|
||||
// TODO: Implement using Windows API
|
||||
throw std::runtime_error("Windows API implementation required");
|
||||
}
|
||||
|
||||
std::string GetSystemInfo()
|
||||
{
|
||||
// TODO: Get Windows system information
|
||||
throw std::runtime_error("Windows API implementation required");
|
||||
}
|
||||
};
|
||||
|
||||
// Linux-specific functionality (interface only)
|
||||
class LinuxPlugin : public IPlugin
|
||||
{
|
||||
public:
|
||||
std::string GetName() const override { return "LinuxPlugin"; }
|
||||
std::string GetVersion() const override { return "1.0.0"; }
|
||||
|
||||
bool Initialize() override
|
||||
{
|
||||
// TODO: Initialize Linux-specific features
|
||||
return true;
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
// TODO: Cleanup Linux-specific resources
|
||||
}
|
||||
|
||||
// Linux-specific methods (interface only)
|
||||
std::string GetSystemInfo()
|
||||
{
|
||||
// TODO: Get Linux system information
|
||||
throw std::runtime_error("Linux API implementation required");
|
||||
}
|
||||
};
|
||||
|
||||
// Factory for platform-specific plugins
|
||||
std::shared_ptr<IPlugin> CreatePlatformPlugin()
|
||||
{
|
||||
if (PlatformIndicator::IsPlatformWindows) {
|
||||
return std::make_shared<WindowsPlugin>();
|
||||
} else if (PlatformIndicator::IsPlatformLinux) {
|
||||
return std::make_shared<LinuxPlugin>();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Plugin helper macros
|
||||
#define DECLARE_PLUGIN(ClassName) \
|
||||
extern "C" Convention::IPlugin* CreatePlugin() { \
|
||||
return new ClassName(); \
|
||||
} \
|
||||
extern "C" void DestroyPlugin(Convention::IPlugin* plugin) { \
|
||||
delete plugin; \
|
||||
}
|
||||
|
||||
#define REGISTER_PLUGIN(ClassName) \
|
||||
bool Register##ClassName() { \
|
||||
return Convention::PluginManager::GetInstance().RegisterPlugin<ClassName>(); \
|
||||
}
|
||||
}
|
||||
|
||||
#endif // Convention_Runtime_Plugins_hpp
|
@@ -1,200 +0,0 @@
|
||||
# Convention-CPP Runtime 模块说明
|
||||
|
||||
本文档描述了基于 `Convention-Template` 为 `Convention-CPP` 实现的Runtime模块。
|
||||
|
||||
## 📁 模块结构
|
||||
|
||||
### 完整实现的模块
|
||||
|
||||
#### 1. **File.hpp** - 文件操作工具
|
||||
- **ToolFile类**: 面向对象的文件系统操作
|
||||
- **完整功能**: 文件读写、路径操作、目录管理
|
||||
- **链式操作**: 支持流畅的API调用
|
||||
- **跨平台**: 基于std::filesystem
|
||||
|
||||
**核心功能**:
|
||||
- 文件存在性检查、类型判断
|
||||
- 文本/二进制文件读写
|
||||
- 目录遍历和管理
|
||||
- 路径组合操作符 `|`
|
||||
- 文件对话框接口(需平台实现)
|
||||
|
||||
#### 2. **GlobalConfig.hpp** - 全局配置管理
|
||||
- **GlobalConfig类**: 配置文件管理和日志系统
|
||||
- **ProjectConfig类**: 项目级配置特化
|
||||
- **JSON支持**: 基于nlohmann/json
|
||||
- **完整功能**: 配置读写、日志记录
|
||||
|
||||
**核心功能**:
|
||||
- 键值对配置管理
|
||||
- 自动配置文件生成
|
||||
- 时间戳日志系统
|
||||
- 迭代器支持(foreach循环)
|
||||
- 文件操作集成
|
||||
|
||||
#### 3. **Math.hpp** - 数学工具库
|
||||
- **完整实现**: 常用数学函数和工具
|
||||
- **模板化**: 支持多种数值类型
|
||||
- **高性能**: 基于标准库优化
|
||||
|
||||
**核心功能**:
|
||||
- 数学常量和基础运算
|
||||
- 三角函数、指数对数函数
|
||||
- 插值函数(Lerp, InverseLerp)
|
||||
- 随机数生成器
|
||||
- 浮点数比较工具
|
||||
|
||||
### 接口实现的模块
|
||||
|
||||
#### 4. **Web.hpp** - 网络工具模块
|
||||
- **ToolURL类**: URL解析和操作
|
||||
- **HttpClient类**: HTTP客户端接口
|
||||
- **接口状态**: 完整API设计,需HTTP库实现
|
||||
|
||||
**设计功能**:
|
||||
- URL验证和属性解析
|
||||
- 文件类型检测
|
||||
- HTTP GET/POST方法
|
||||
- 异步下载功能
|
||||
- URL编码/解码
|
||||
|
||||
**实现要求**: 需要libcurl或类似HTTP库
|
||||
|
||||
#### 5. **Plugins.hpp** - 插件系统
|
||||
- **PriorityQueue类**: 完整的优先队列实现
|
||||
- **IPlugin接口**: 插件基类定义
|
||||
- **PluginManager类**: 插件管理器接口
|
||||
|
||||
**设计功能**:
|
||||
- 动态插件加载/卸载
|
||||
- 插件依赖管理
|
||||
- 平台特定插件支持
|
||||
- 事件系统集成
|
||||
- 优先级队列调度
|
||||
|
||||
**实现要求**: 需要动态库加载机制
|
||||
|
||||
#### 6. **EasySave.hpp** - 序列化系统
|
||||
- **EasySave类**: 主要序列化接口
|
||||
- **EasySaveSettings**: 配置结构
|
||||
- **接口状态**: 基础JSON实现,完整功能需扩展
|
||||
|
||||
**设计功能**:
|
||||
- 多格式序列化(JSON/Binary)
|
||||
- 加密和压缩支持
|
||||
- 缓存系统
|
||||
- 备份/恢复机制
|
||||
- 键值管理
|
||||
|
||||
**实现要求**: 需要加密库和压缩库
|
||||
|
||||
### 继承的模块
|
||||
|
||||
#### 7. **Config.hpp** - 基础配置(已存在)
|
||||
- **完整实现**: 平台判断、字符串工具、内存管理
|
||||
- **基础设施**: 为其他模块提供基础功能
|
||||
|
||||
#### 8. **Architecture.hpp** - 核心架构(已存在)
|
||||
- **完整实现**: 依赖注入、事件系统、时间线管理
|
||||
- **设计模式**: 单例、依赖注入、观察者模式
|
||||
|
||||
## 🔧 编译配置
|
||||
|
||||
### 依赖库
|
||||
- **标准库**: C++17 std::filesystem
|
||||
- **可选依赖**: nlohmann/json(配置管理)
|
||||
- **待实现依赖**:
|
||||
- libcurl(Web模块)
|
||||
- OpenSSL/AES库(EasySave加密)
|
||||
- zlib(EasySave压缩)
|
||||
|
||||
### CMake配置
|
||||
已在主CMakeLists.txt中添加依赖查找:
|
||||
```cmake
|
||||
find_package(nlohmann_json QUIET)
|
||||
```
|
||||
|
||||
## 🚀 使用示例
|
||||
|
||||
### 文件操作
|
||||
```cpp
|
||||
#include "Convention/[Runtime]/File.hpp"
|
||||
using namespace Convention;
|
||||
|
||||
ToolFile file("data/config.txt");
|
||||
if (file.Exists()) {
|
||||
auto content = file.LoadAsText();
|
||||
// 处理内容
|
||||
}
|
||||
|
||||
// 链式操作
|
||||
ToolFile dataDir("assets");
|
||||
auto configFile = dataDir | "config" | "settings.json";
|
||||
```
|
||||
|
||||
### 配置管理
|
||||
```cpp
|
||||
#include "Convention/[Runtime]/GlobalConfig.hpp"
|
||||
using namespace Convention;
|
||||
|
||||
GlobalConfig config("./data");
|
||||
config["username"] = "player1";
|
||||
config["level"] = 5;
|
||||
config.SaveProperties();
|
||||
|
||||
// 日志记录
|
||||
config.Log("Info", "Game started");
|
||||
```
|
||||
|
||||
### 数学运算
|
||||
```cpp
|
||||
#include "Convention/[Runtime]/Math.hpp"
|
||||
using namespace Convention;
|
||||
|
||||
auto result = Math::Sin(Math::DegToRad(90.0f));
|
||||
auto random_value = Math::RandomRange(1, 100);
|
||||
bool is_equal = Math::Equal(3.14f, Math::Constants<float>::PI, 0.01f);
|
||||
```
|
||||
|
||||
## 📋 实现状态总结
|
||||
|
||||
| 模块 | 状态 | 完成度 | 备注 |
|
||||
|------|------|--------|------|
|
||||
| Config | ✅ 完整 | 100% | 已存在 |
|
||||
| Architecture | ✅ 完整 | 100% | 已存在 |
|
||||
| File | ✅ 完整 | 95% | 平台对话框需实现 |
|
||||
| GlobalConfig | ✅ 完整 | 100% | 功能完整 |
|
||||
| Math | ✅ 完整 | 100% | 功能完整 |
|
||||
| Web | 🔧 接口 | 30% | 需HTTP库实现 |
|
||||
| Plugins | 🔧 接口 | 40% | 需动态加载实现 |
|
||||
| EasySave | 🔧 接口 | 20% | 需加密压缩实现 |
|
||||
|
||||
## 🎯 下一步实现建议
|
||||
|
||||
### 高优先级
|
||||
1. **完善Web模块**: 集成libcurl实现HTTP功能
|
||||
2. **完善EasySave**: 实现完整的序列化系统
|
||||
3. **文件对话框**: 实现平台特定的文件选择功能
|
||||
|
||||
### 中优先级
|
||||
1. **插件系统**: 实现动态库加载机制
|
||||
2. **加密支持**: 为EasySave添加AES加密
|
||||
3. **压缩支持**: 为EasySave添加Gzip压缩
|
||||
|
||||
### 低优先级
|
||||
1. **性能优化**: 针对关键路径进行优化
|
||||
2. **单元测试**: 为各模块添加测试用例
|
||||
3. **文档完善**: 添加详细的API文档
|
||||
|
||||
## 📚 设计原则
|
||||
|
||||
本实现遵循以下设计原则:
|
||||
|
||||
1. **模块化**: 每个模块功能独立,依赖关系清晰
|
||||
2. **类型安全**: 大量使用模板和类型检查
|
||||
3. **RAII**: 资源管理遵循RAII原则
|
||||
4. **异常安全**: 提供清晰的错误处理机制
|
||||
5. **跨平台**: 基于标准库,支持主要平台
|
||||
6. **向前兼容**: 接口设计考虑未来扩展性
|
||||
|
||||
这个实现为Convention-CPP提供了完整的Runtime基础设施,为后续开发提供了坚实的基础。
|
Reference in New Issue
Block a user