#pragma once #include "simsbasic.h" #include /// /// 内存实体实例类型 /// class SIMSBASIC_EXPORT RtWsEntity : public WsEntity, public ComponentSet, public std::enable_shared_from_this { private: uint64_t _entity_id = 0; QString _templet_name, _runtime_name; QHash> _comps_list; public: explicit RtWsEntity(); virtual ~RtWsEntity() = default; /// /// 重置本实例模板名 /// /// 模板名称 virtual void resetTemplet(const QString& name); /// /// 获取本实例的模板名 /// /// 模板名称 virtual QString templetName() const; /// /// 重置本实例的运行ID /// /// virtual void resetID(uint64_t id); /// /// 获取本实例的运行ID /// /// virtual uint64_t entityID() const; /// /// 重置本实例的运行名称 /// /// virtual void resetName(const QString& name); /// /// 获取本实例的运行名称 /// /// 运行名称 virtual QString name() const; /// /// 为本实例添加指定类型的插件 /// /// virtual void append(std::shared_ptr ins) override; /// /// 移除指定类型的插件实例 /// /// virtual void remove(const QString& component_type) override; /// /// 获取本实例内包含的所有插件实例 /// /// virtual QList> components() const override; /// /// 深度克隆本实例,插件和数据一致 /// /// virtual std::shared_ptr defaultNew() const; /// /// 允许输入的消息类型 /// /// 消息类型集合 virtual QList inputTypes() const; /// /// 通过指定的签名获取处理入口 /// /// 签名 /// 处理接口 virtual QList getEntryWithSignature(const WsRespondSignatureType& t) const; /// /// 通过输入消息类型获取处理入口 /// /// 输入消息类型 /// 处理接口列表 virtual QList getEntryWithInType(const QString& msg_type) const; // 通过 Serializable 继承 void recoveryFrom(const QJsonObject& obj) override; void saveTo(QJsonObject& obj) const override; }; /// /// 运行时实体管理器 /// class SIMSBASIC_EXPORT RtEntityManager : public WsEntity, public ComponentSet, public std::enable_shared_from_this { public: static const uint64_t const_id = 0x01ff; QHash> _comps_list; QString templetName() const override; uint64_t entityID() const override; QString name() const override; void append(std::shared_ptr ins) override; void remove(const QString& component_type) override; QList> components() const override; std::shared_ptr defaultNew() const override; QList getEntryWithSignature(const WsRespondSignatureType& t) const override; QList getEntryWithInType(const QString& msg_type) const override; void recoveryFrom(const QJsonObject& obj) override; void saveTo(QJsonObject& obj) const override; }; class SIMSBASIC_EXPORT RtResourceManager : public WsEntity, public ComponentSet, public std::enable_shared_from_this { public: static const uint64_t const_id = 0x01f0; QHash> _comps_list; QString templetName() const override; uint64_t entityID() const override; QString name() const override; std::shared_ptr defaultNew() const override; QList getEntryWithSignature(const WsRespondSignatureType& t) const override; QList getEntryWithInType(const QString& msg_type) const override; void recoveryFrom(const QJsonObject& obj) override; void saveTo(QJsonObject& obj) const override; void append(std::shared_ptr ins) override; void remove(const QString& component_type) override; QList> components() const override; }; /// /// 实体内迅捷调用核心 /// class SIMSBASIC_EXPORT ImmediateKernel : public Immediate, public std::enable_shared_from_this { private: std::shared_ptr _bind_entity = nullptr; public: ImmediateKernel(std::shared_ptr bind); /// /// 获取实体管理器id /// /// virtual uint64_t entityManagerID() const override; virtual uint64_t resourceManagerID() const override; /// /// 实体内指定类型的调用立即执行 /// /// /// virtual QList> execute(const WsRespondSignatureType& resp_signature, std::shared_ptr in) override; /// /// 实体内兼容调用立即执行 /// /// /// virtual QList> execute(std::shared_ptr in) override; };