From c76bff7a50abbe0d5fcfcd85d6344bdbd17fcd6d Mon Sep 17 00:00:00 2001 From: codeboss <2422523675@qq.com> Date: Thu, 10 Jul 2025 08:04:21 +0800 Subject: [PATCH] update --- ComponentBasic/ComponentBasic.vcxproj | 2 +- ComponentBasic/ComponentsInfoPull.cpp | 2 +- ComponentBasic/DeduceFramework.cpp | 6 +++--- ComponentBasic/DeduceFramework.h | 4 ++-- ComponentBasic/VisibleCube.cpp | 5 +++++ ComponentBasic/VisibleCube.h | 1 + ComponentBasic/componentbasic.h | 4 ++-- MessageBasic/MessageBasic.vcxproj | 2 +- SimsBasic/SimsBasic.vcxproj | 2 +- SimsBasic/internal_impl.cpp | 14 +++++++------- SimsBasic/internal_impl.h | 18 +++++++++--------- SimsBasic/simsbasic.h | 23 ++++++++++++++++++++--- SimsWorld/SimsWorld.vcxproj | 2 +- StandardGlobe/StandardGlobe.vcxproj | 2 +- TestProject/TestProject.vcxproj | 2 +- 15 files changed, 56 insertions(+), 33 deletions(-) diff --git a/ComponentBasic/ComponentBasic.vcxproj b/ComponentBasic/ComponentBasic.vcxproj index 9d3a0c9..79e73fa 100644 --- a/ComponentBasic/ComponentBasic.vcxproj +++ b/ComponentBasic/ComponentBasic.vcxproj @@ -36,7 +36,7 @@ - 5.12.9_msvc2017_64 + 5.12.11_msvc2017_64 core;xml;gui;qml;concurrent debug diff --git a/ComponentBasic/ComponentsInfoPull.cpp b/ComponentBasic/ComponentsInfoPull.cpp index 868bc7e..e51156f 100644 --- a/ComponentBasic/ComponentsInfoPull.cpp +++ b/ComponentBasic/ComponentsInfoPull.cpp @@ -25,7 +25,7 @@ void ComponentsInfoPull::execute( rst->_entity_json["entity_id"] = QJsonValue::fromVariant(QVariant::fromValue(bind_e->entityID())); rst->_entity_json["entity_name"] = bind_e->name(); - QList> comp_list; + QList> comp_list; auto host_conv = std::dynamic_pointer_cast(bind_e); comp_list = host_conv->components(); diff --git a/ComponentBasic/DeduceFramework.cpp b/ComponentBasic/DeduceFramework.cpp index 40b65f4..994f5d6 100644 --- a/ComponentBasic/DeduceFramework.cpp +++ b/ComponentBasic/DeduceFramework.cpp @@ -308,7 +308,7 @@ void DeduceFramework::execute( QStringList exists_component_types; std::transform(comps_list.begin(), comps_list.end(), std::back_inserter(exists_component_types), - [](std::shared_ptr c) { return c->name(); }); + [](std::shared_ptr c) { return c->name(); }); for (auto comp : in->_component_types) { if (!exists_component_types.contains(comp)) { @@ -333,13 +333,13 @@ ComponentFactory::ComponentFactory() _comp_types[ins1->name()] = ins1; } -std::shared_ptr ComponentFactory::makeNew(const QString& type) +std::shared_ptr ComponentFactory::makeNew(const QString& type) { if (!this->_comp_types.contains(type)) return NULL; auto ntype = _comp_types[type]; - return std::static_pointer_cast(ntype->newDefault()); + return std::static_pointer_cast(ntype->newDefault()); } QList ComponentFactory::allComponentTypes() const diff --git a/ComponentBasic/DeduceFramework.h b/ComponentBasic/DeduceFramework.h index 1923d6a..3acfdde 100644 --- a/ComponentBasic/DeduceFramework.h +++ b/ComponentBasic/DeduceFramework.h @@ -9,12 +9,12 @@ class COMPONENTBASIC_EXPORT ComponentFactory : public Serializable { private: - QHash> _comp_types; + QHash> _comp_types; public: ComponentFactory(); - std::shared_ptr makeNew(const QString &type); + std::shared_ptr makeNew(const QString &type); QList allComponentTypes() const; // 通过 Serializable 继承 diff --git a/ComponentBasic/VisibleCube.cpp b/ComponentBasic/VisibleCube.cpp index ae770f6..133408f 100644 --- a/ComponentBasic/VisibleCube.cpp +++ b/ComponentBasic/VisibleCube.cpp @@ -40,6 +40,11 @@ std::shared_ptr VisibleCubePlugin::newDefault() const { return copy; } +QString VisibleCubePlugin::bindDataTopic() const +{ + return ""; +} + void VisibleCubePlugin::bindEntity(std::weak_ptr ins) { this->_bind_entity = ins; diff --git a/ComponentBasic/VisibleCube.h b/ComponentBasic/VisibleCube.h index f2b2fb5..a7b1414 100644 --- a/ComponentBasic/VisibleCube.h +++ b/ComponentBasic/VisibleCube.h @@ -25,6 +25,7 @@ public: explicit VisibleCubePlugin() = default; // 通过 ProcList 继承 + QString bindDataTopic() const override; void bindEntity(std::weak_ptr ins) override; QString name() const override; diff --git a/ComponentBasic/componentbasic.h b/ComponentBasic/componentbasic.h index f5e79ec..8d14cb0 100644 --- a/ComponentBasic/componentbasic.h +++ b/ComponentBasic/componentbasic.h @@ -73,7 +73,7 @@ struct _RespondRoute : public _RespondRoute, /// /// template -struct RespondRoute : virtual public WsComponent, public _RespondRoute { +struct RespondRoute : virtual public WsSpecializedSystem, public _RespondRoute { RespondRoute() : _RespondRoute() {} // 通过 WsComponent 继承 @@ -194,7 +194,7 @@ struct _RequestRoute : public _RequestRoute, /// /// template -struct RequestRoute : virtual public WsComponent, public _RequestRoute { +struct RequestRoute : virtual public WsSpecializedSystem, public _RequestRoute { RequestRoute() : _RequestRoute() {} virtual QList requestSignatures() const { return _RequestRoute<>::_request_list; diff --git a/MessageBasic/MessageBasic.vcxproj b/MessageBasic/MessageBasic.vcxproj index 0a98f7f..60cb910 100644 --- a/MessageBasic/MessageBasic.vcxproj +++ b/MessageBasic/MessageBasic.vcxproj @@ -36,7 +36,7 @@ - 5.12.9_msvc2017_64 + 5.12.11_msvc2017_64 core;gui debug diff --git a/SimsBasic/SimsBasic.vcxproj b/SimsBasic/SimsBasic.vcxproj index 1a73115..7abe405 100644 --- a/SimsBasic/SimsBasic.vcxproj +++ b/SimsBasic/SimsBasic.vcxproj @@ -36,7 +36,7 @@ - 5.12.9_msvc2017_64 + 5.12.11_msvc2017_64 core debug diff --git a/SimsBasic/internal_impl.cpp b/SimsBasic/internal_impl.cpp index 648f19d..c35f362 100644 --- a/SimsBasic/internal_impl.cpp +++ b/SimsBasic/internal_impl.cpp @@ -27,7 +27,7 @@ QString RtWsEntity::name() const { return this->_runtime_name; } -void RtWsEntity::append(std::shared_ptr ins) { +void RtWsEntity::append(std::shared_ptr ins) { if (this->_comps_list.contains(ins->name())) return; @@ -39,7 +39,7 @@ void RtWsEntity::remove(const QString& component_type) { this->_comps_list.remove(component_type); } -QList> RtWsEntity::components() const { +QList> RtWsEntity::components() const { return _comps_list.values(); } @@ -50,7 +50,7 @@ std::shared_ptr RtWsEntity::newDefault() const { newx->_runtime_name = this->_runtime_name; for (auto c : this->_comps_list) - newx->append(std::static_pointer_cast(c->newDefault())); + newx->append(std::static_pointer_cast(c->newDefault())); return newx; } @@ -134,7 +134,7 @@ QString RtEntityManager::name() const return "实体管理器唯一实例"; } -void RtEntityManager::append(std::shared_ptr ins) { +void RtEntityManager::append(std::shared_ptr ins) { ins->bindEntity(this->shared_from_this()); _comps_list[ins->name()] = ins; } @@ -193,7 +193,7 @@ void RtEntityManager::remove(const QString& component_type) this->_comps_list.remove(component_type); } -QList> RtEntityManager::components() const +QList> RtEntityManager::components() const { return this->_comps_list.values(); } @@ -262,7 +262,7 @@ void RtResourceManager::saveTo(QJsonObject& obj) const obj["component_array"] = array; } -void RtResourceManager::append(std::shared_ptr ins) +void RtResourceManager::append(std::shared_ptr ins) { ins->bindEntity(this->shared_from_this()); this->_comps_list[ins->name()] = ins; @@ -273,7 +273,7 @@ void RtResourceManager::remove(const QString& component_type) this->_comps_list.remove(component_type); } -QList> RtResourceManager::components() const +QList> RtResourceManager::components() const { return this->_comps_list.values(); } diff --git a/SimsBasic/internal_impl.h b/SimsBasic/internal_impl.h index a5f1e9e..7ceb506 100644 --- a/SimsBasic/internal_impl.h +++ b/SimsBasic/internal_impl.h @@ -10,7 +10,7 @@ class SIMSBASIC_EXPORT RtWsEntity : public WsEntity, public ComponentSet, public private: uint64_t _entity_id = 0; QString _templet_name, _runtime_name; - QHash> _comps_list; + QHash> _comps_list; public: explicit RtWsEntity(); @@ -52,7 +52,7 @@ public: /// 为本实例添加指定类型的插件 /// /// - virtual void append(std::shared_ptr ins) override; + virtual void append(std::shared_ptr ins) override; /// /// 移除指定类型的插件实例 /// @@ -62,7 +62,7 @@ public: /// 获取本实例内包含的所有插件实例 /// /// - virtual QList> components() const override; + virtual QList> components() const override; /// /// 深度克隆本实例,插件和数据一致 @@ -101,14 +101,14 @@ class SIMSBASIC_EXPORT RtEntityManager : public WsEntity, public ComponentSet, { public: static const uint64_t const_id = 0x01ff; - QHash> _comps_list; + QHash> _comps_list; QString templetName() const override; uint64_t entityID() const override; QString name() const override; - void append(std::shared_ptr ins) override; + void append(std::shared_ptr ins) override; void remove(const QString& component_type) override; - QList> components() const override; + QList> components() const override; std::shared_ptr newDefault() const override; QList getRespondWithSignature(const WsRespondSignatureType& t) const override; @@ -123,7 +123,7 @@ class SIMSBASIC_EXPORT RtResourceManager : public WsEntity, public ComponentSet, { public: static const uint64_t const_id = 0x01f0; - QHash> _comps_list; + QHash> _comps_list; QString templetName() const override; uint64_t entityID() const override; @@ -136,8 +136,8 @@ public: void recoveryFrom(const QJsonObject& obj) override; void saveTo(QJsonObject& obj) const override; - void append(std::shared_ptr ins) override; + void append(std::shared_ptr ins) override; void remove(const QString& component_type) override; - QList> components() const override; + QList> components() const override; }; diff --git a/SimsBasic/simsbasic.h b/SimsBasic/simsbasic.h index 04e2b00..1d9aa52 100644 --- a/SimsBasic/simsbasic.h +++ b/SimsBasic/simsbasic.h @@ -54,6 +54,18 @@ public: virtual QString topicString() const = 0; }; +/// +/// 特殊用途的数据 +/// +class WsSpecializedData : public TopicData { +public: + /// + /// 内存尺寸 + /// + /// + virtual uint32_t inMemSize() const = 0; +}; + /// /// 通用消息基类 /// @@ -126,8 +138,13 @@ public: /// /// 功能插件的基类 /// -class WsComponent : public Serializable, public std::enable_shared_from_this { +class WsSpecializedSystem : public Serializable, public std::enable_shared_from_this { public: + /// + /// 针对指定数据Topic + /// + /// + virtual QString bindDataTopic() const = 0; /// /// 插件唯一命名 /// @@ -174,7 +191,7 @@ public: /// 为本实例添加指定类型的插件 /// /// - virtual void append(std::shared_ptr ins) = 0; + virtual void append(std::shared_ptr ins) = 0; /// /// 移除指定类型的插件实例 /// @@ -184,5 +201,5 @@ public: /// 获取本实例内包含的所有插件实例 /// /// - virtual QList> components() const = 0; + virtual QList> components() const = 0; }; diff --git a/SimsWorld/SimsWorld.vcxproj b/SimsWorld/SimsWorld.vcxproj index 96a872b..008c2d7 100644 --- a/SimsWorld/SimsWorld.vcxproj +++ b/SimsWorld/SimsWorld.vcxproj @@ -36,7 +36,7 @@ - 5.12.9_msvc2017_64 + 5.12.11_msvc2017_64 core;gui;widgets;qml debug diff --git a/StandardGlobe/StandardGlobe.vcxproj b/StandardGlobe/StandardGlobe.vcxproj index e7ecadd..a91c0de 100644 --- a/StandardGlobe/StandardGlobe.vcxproj +++ b/StandardGlobe/StandardGlobe.vcxproj @@ -36,7 +36,7 @@ - 5.12.9_msvc2017_64 + 5.12.11_msvc2017_64 core;gui debug diff --git a/TestProject/TestProject.vcxproj b/TestProject/TestProject.vcxproj index d1abf9c..3302cf4 100644 --- a/TestProject/TestProject.vcxproj +++ b/TestProject/TestProject.vcxproj @@ -36,7 +36,7 @@ - 5.12.9_msvc2017_64 + 5.12.11_msvc2017_64 core;gui debug