diff --git a/ComponentBasic/ComponentsInfoPull.cpp b/ComponentBasic/ComponentsInfoPull.cpp index e51156f..868bc7e 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 994f5d6..40b65f4 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 3acfdde..1923d6a 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 133408f..ae770f6 100644 --- a/ComponentBasic/VisibleCube.cpp +++ b/ComponentBasic/VisibleCube.cpp @@ -40,11 +40,6 @@ 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 a7b1414..f2b2fb5 100644 --- a/ComponentBasic/VisibleCube.h +++ b/ComponentBasic/VisibleCube.h @@ -25,7 +25,6 @@ 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 8d14cb0..f5e79ec 100644 --- a/ComponentBasic/componentbasic.h +++ b/ComponentBasic/componentbasic.h @@ -73,7 +73,7 @@ struct _RespondRoute : public _RespondRoute, /// /// template -struct RespondRoute : virtual public WsSpecializedSystem, public _RespondRoute { +struct RespondRoute : virtual public WsComponent, public _RespondRoute { RespondRoute() : _RespondRoute() {} // 通过 WsComponent 继承 @@ -194,7 +194,7 @@ struct _RequestRoute : public _RequestRoute, /// /// template -struct RequestRoute : virtual public WsSpecializedSystem, public _RequestRoute { +struct RequestRoute : virtual public WsComponent, public _RequestRoute { RequestRoute() : _RequestRoute() {} virtual QList requestSignatures() const { return _RequestRoute<>::_request_list; diff --git a/SimsBasic/internal_impl.cpp b/SimsBasic/internal_impl.cpp index c35f362..648f19d 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 7ceb506..a5f1e9e 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.cpp b/SimsBasic/simsbasic.cpp index 5df5d10..64b1d20 100644 --- a/SimsBasic/simsbasic.cpp +++ b/SimsBasic/simsbasic.cpp @@ -9,3 +9,14 @@ QString UniException::content() const noexcept { return _error_store; } + +#include "internal_impl.h" +uint64_t PublicTable::entityManagerAddress() +{ + return RtEntityManager::const_id; +} + +uint64_t PublicTable::resourceManagerAddress() +{ + return RtResourceManager::const_id; +} diff --git a/SimsBasic/simsbasic.h b/SimsBasic/simsbasic.h index 1d9aa52..0bef6c6 100644 --- a/SimsBasic/simsbasic.h +++ b/SimsBasic/simsbasic.h @@ -19,6 +19,8 @@ public: virtual QString content() const noexcept; }; +// ======================================================= + /// /// 可序列化对象 /// @@ -54,18 +56,6 @@ public: virtual QString topicString() const = 0; }; -/// -/// 特殊用途的数据 -/// -class WsSpecializedData : public TopicData { -public: - /// - /// 内存尺寸 - /// - /// - virtual uint32_t inMemSize() const = 0; -}; - /// /// 通用消息基类 /// @@ -83,6 +73,7 @@ public: /// ID virtual uint64_t sourceEntity() const = 0; }; +// ================================================================ /// /// Respond签名类型 @@ -97,6 +88,23 @@ using WsRequestSignatureType = std::pair; /// using WsRespondEntry = std::function, QList>&)>; +/// +/// 对外开放地址表 +/// +struct PublicTable { + /// + /// 实体管理器地址 + /// + /// + static uint64_t entityManagerAddress(); + /// + /// 资源管理器地址 + /// + /// + static uint64_t resourceManagerAddress(); +}; + + /// /// 实体抽象接口 /// @@ -135,16 +143,12 @@ public: virtual QList getRespondWithInType(const QString& msg_type) const = 0; }; + /// /// 功能插件的基类 /// -class WsSpecializedSystem : public Serializable, public std::enable_shared_from_this { +class WsComponent : public Serializable, public std::enable_shared_from_this { public: - /// - /// 针对指定数据Topic - /// - /// - virtual QString bindDataTopic() const = 0; /// /// 插件唯一命名 /// @@ -156,12 +160,6 @@ public: /// /// 实体实例 virtual void bindEntity(std::weak_ptr host) = 0; - - /// - /// 允许发送的消息类型签名 - /// - /// - virtual QList requestSignatures() const = 0; /// /// 允许响应处理的消息签名类型 @@ -181,7 +179,6 @@ public: /// 处理接口列表 virtual QList getRespondWithInType(const QString& msg_type) const = 0; }; - /// /// 组件管理接口 /// @@ -191,7 +188,7 @@ public: /// 为本实例添加指定类型的插件 /// /// - virtual void append(std::shared_ptr ins) = 0; + virtual void append(std::shared_ptr ins) = 0; /// /// 移除指定类型的插件实例 /// @@ -201,5 +198,34 @@ public: /// 获取本实例内包含的所有插件实例 /// /// - virtual QList> components() const = 0; + virtual QList> components() const = 0; }; + + +/// +/// 批量处理单元通用接口 +/// +using WsBatchRespondEntry = std::function>&, const QList>&, QList>&)>; +/// +/// 批量处理拓展 +/// +class WsBatchComponent : public Serializable, public std::enable_shared_from_this{ +public: + /// + /// 插件唯一命名 + /// + /// 插件名 + virtual QString name() const = 0; + + /// + /// 允许响应处理的消息签名类型 + /// + /// 消息签名类型集合 + virtual QList respondSignatures() const = 0; + /// + /// 通过输入消息类型获取处理入口 + /// + /// 输入消息类型 + /// 处理接口列表 + virtual QList getRespondWithInType(const QString& msg_type) const = 0; +}; \ No newline at end of file