Compare commits
2 Commits
c76bff7a50
...
7614790ce2
Author | SHA1 | Date |
---|---|---|
|
7614790ce2 | |
|
8d42261f18 |
|
@ -25,7 +25,7 @@ void ComponentsInfoPull::execute(
|
||||||
rst->_entity_json["entity_id"] = QJsonValue::fromVariant(QVariant::fromValue(bind_e->entityID()));
|
rst->_entity_json["entity_id"] = QJsonValue::fromVariant(QVariant::fromValue(bind_e->entityID()));
|
||||||
rst->_entity_json["entity_name"] = bind_e->name();
|
rst->_entity_json["entity_name"] = bind_e->name();
|
||||||
|
|
||||||
QList<std::shared_ptr<WsSpecializedSystem>> comp_list;
|
QList<std::shared_ptr<WsComponent>> comp_list;
|
||||||
auto host_conv = std::dynamic_pointer_cast<ComponentSet>(bind_e);
|
auto host_conv = std::dynamic_pointer_cast<ComponentSet>(bind_e);
|
||||||
comp_list = host_conv->components();
|
comp_list = host_conv->components();
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ void DeduceFramework::execute(
|
||||||
QStringList exists_component_types;
|
QStringList exists_component_types;
|
||||||
std::transform(comps_list.begin(), comps_list.end(),
|
std::transform(comps_list.begin(), comps_list.end(),
|
||||||
std::back_inserter(exists_component_types),
|
std::back_inserter(exists_component_types),
|
||||||
[](std::shared_ptr<WsSpecializedSystem> c) { return c->name(); });
|
[](std::shared_ptr<WsComponent> c) { return c->name(); });
|
||||||
|
|
||||||
for (auto comp : in->_component_types) {
|
for (auto comp : in->_component_types) {
|
||||||
if (!exists_component_types.contains(comp)) {
|
if (!exists_component_types.contains(comp)) {
|
||||||
|
@ -333,13 +333,13 @@ ComponentFactory::ComponentFactory()
|
||||||
_comp_types[ins1->name()] = ins1;
|
_comp_types[ins1->name()] = ins1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<WsSpecializedSystem> ComponentFactory::makeNew(const QString& type)
|
std::shared_ptr<WsComponent> ComponentFactory::makeNew(const QString& type)
|
||||||
{
|
{
|
||||||
if (!this->_comp_types.contains(type))
|
if (!this->_comp_types.contains(type))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
auto ntype = _comp_types[type];
|
auto ntype = _comp_types[type];
|
||||||
return std::static_pointer_cast<WsSpecializedSystem>(ntype->newDefault());
|
return std::static_pointer_cast<WsComponent>(ntype->newDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> ComponentFactory::allComponentTypes() const
|
QList<QString> ComponentFactory::allComponentTypes() const
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
|
|
||||||
class COMPONENTBASIC_EXPORT ComponentFactory : public Serializable {
|
class COMPONENTBASIC_EXPORT ComponentFactory : public Serializable {
|
||||||
private:
|
private:
|
||||||
QHash<QString, std::shared_ptr<WsSpecializedSystem>> _comp_types;
|
QHash<QString, std::shared_ptr<WsComponent>> _comp_types;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ComponentFactory();
|
ComponentFactory();
|
||||||
|
|
||||||
std::shared_ptr<WsSpecializedSystem> makeNew(const QString &type);
|
std::shared_ptr<WsComponent> makeNew(const QString &type);
|
||||||
QList<QString> allComponentTypes() const;
|
QList<QString> allComponentTypes() const;
|
||||||
|
|
||||||
// 通过 Serializable 继承
|
// 通过 Serializable 继承
|
||||||
|
|
|
@ -40,11 +40,6 @@ std::shared_ptr<Serializable> VisibleCubePlugin::newDefault() const {
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VisibleCubePlugin::bindDataTopic() const
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void VisibleCubePlugin::bindEntity(std::weak_ptr<WsEntity> ins)
|
void VisibleCubePlugin::bindEntity(std::weak_ptr<WsEntity> ins)
|
||||||
{
|
{
|
||||||
this->_bind_entity = ins;
|
this->_bind_entity = ins;
|
||||||
|
|
|
@ -25,7 +25,6 @@ public:
|
||||||
explicit VisibleCubePlugin() = default;
|
explicit VisibleCubePlugin() = default;
|
||||||
|
|
||||||
// 通过 ProcList 继承
|
// 通过 ProcList 继承
|
||||||
QString bindDataTopic() const override;
|
|
||||||
void bindEntity(std::weak_ptr<WsEntity> ins) override;
|
void bindEntity(std::weak_ptr<WsEntity> ins) override;
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct _RespondRoute<RespSig, RespSigs...> : public _RespondRoute<RespSigs...>,
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="...Resp"></typeparam>
|
/// <typeparam name="...Resp"></typeparam>
|
||||||
template <typename... Resp>
|
template <typename... Resp>
|
||||||
struct RespondRoute : virtual public WsSpecializedSystem, public _RespondRoute<Resp...> {
|
struct RespondRoute : virtual public WsComponent, public _RespondRoute<Resp...> {
|
||||||
RespondRoute() : _RespondRoute<Resp...>() {}
|
RespondRoute() : _RespondRoute<Resp...>() {}
|
||||||
|
|
||||||
// ͨ¹ý WsComponent ¼Ì³Ð
|
// ͨ¹ý WsComponent ¼Ì³Ð
|
||||||
|
@ -194,7 +194,7 @@ struct _RequestRoute<ReqsSig, ReqsSigs...> : public _RequestRoute<ReqsSigs...>,
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="...Reqs"></typeparam>
|
/// <typeparam name="...Reqs"></typeparam>
|
||||||
template<typename... Reqs>
|
template<typename... Reqs>
|
||||||
struct RequestRoute : virtual public WsSpecializedSystem, public _RequestRoute<Reqs...> {
|
struct RequestRoute : virtual public WsComponent, public _RequestRoute<Reqs...> {
|
||||||
RequestRoute() : _RequestRoute<Reqs...>() {}
|
RequestRoute() : _RequestRoute<Reqs...>() {}
|
||||||
virtual QList<WsRequestSignatureType> requestSignatures() const {
|
virtual QList<WsRequestSignatureType> requestSignatures() const {
|
||||||
return _RequestRoute<>::_request_list;
|
return _RequestRoute<>::_request_list;
|
||||||
|
|
|
@ -27,7 +27,7 @@ QString RtWsEntity::name() const {
|
||||||
return this->_runtime_name;
|
return this->_runtime_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtWsEntity::append(std::shared_ptr<WsSpecializedSystem> ins) {
|
void RtWsEntity::append(std::shared_ptr<WsComponent> ins) {
|
||||||
if (this->_comps_list.contains(ins->name()))
|
if (this->_comps_list.contains(ins->name()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ void RtWsEntity::remove(const QString& component_type) {
|
||||||
this->_comps_list.remove(component_type);
|
this->_comps_list.remove(component_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<WsSpecializedSystem>> RtWsEntity::components() const {
|
QList<std::shared_ptr<WsComponent>> RtWsEntity::components() const {
|
||||||
return _comps_list.values();
|
return _comps_list.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ std::shared_ptr<Serializable> RtWsEntity::newDefault() const {
|
||||||
newx->_runtime_name = this->_runtime_name;
|
newx->_runtime_name = this->_runtime_name;
|
||||||
|
|
||||||
for (auto c : this->_comps_list)
|
for (auto c : this->_comps_list)
|
||||||
newx->append(std::static_pointer_cast<WsSpecializedSystem>(c->newDefault()));
|
newx->append(std::static_pointer_cast<WsComponent>(c->newDefault()));
|
||||||
return newx;
|
return newx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ QString RtEntityManager::name() const
|
||||||
return "ʵÌå¹ÜÀíÆ÷ΨһʵÀý";
|
return "ʵÌå¹ÜÀíÆ÷ΨһʵÀý";
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtEntityManager::append(std::shared_ptr<WsSpecializedSystem> ins) {
|
void RtEntityManager::append(std::shared_ptr<WsComponent> ins) {
|
||||||
ins->bindEntity(this->shared_from_this());
|
ins->bindEntity(this->shared_from_this());
|
||||||
_comps_list[ins->name()] = ins;
|
_comps_list[ins->name()] = ins;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ void RtEntityManager::remove(const QString& component_type)
|
||||||
this->_comps_list.remove(component_type);
|
this->_comps_list.remove(component_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<WsSpecializedSystem>> RtEntityManager::components() const
|
QList<std::shared_ptr<WsComponent>> RtEntityManager::components() const
|
||||||
{
|
{
|
||||||
return this->_comps_list.values();
|
return this->_comps_list.values();
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ void RtResourceManager::saveTo(QJsonObject& obj) const
|
||||||
obj["component_array"] = array;
|
obj["component_array"] = array;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtResourceManager::append(std::shared_ptr<WsSpecializedSystem> ins)
|
void RtResourceManager::append(std::shared_ptr<WsComponent> ins)
|
||||||
{
|
{
|
||||||
ins->bindEntity(this->shared_from_this());
|
ins->bindEntity(this->shared_from_this());
|
||||||
this->_comps_list[ins->name()] = ins;
|
this->_comps_list[ins->name()] = ins;
|
||||||
|
@ -273,7 +273,7 @@ void RtResourceManager::remove(const QString& component_type)
|
||||||
this->_comps_list.remove(component_type);
|
this->_comps_list.remove(component_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<WsSpecializedSystem>> RtResourceManager::components() const
|
QList<std::shared_ptr<WsComponent>> RtResourceManager::components() const
|
||||||
{
|
{
|
||||||
return this->_comps_list.values();
|
return this->_comps_list.values();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ class SIMSBASIC_EXPORT RtWsEntity : public WsEntity, public ComponentSet, public
|
||||||
private:
|
private:
|
||||||
uint64_t _entity_id = 0;
|
uint64_t _entity_id = 0;
|
||||||
QString _templet_name, _runtime_name;
|
QString _templet_name, _runtime_name;
|
||||||
QHash<QString, std::shared_ptr<WsSpecializedSystem>> _comps_list;
|
QHash<QString, std::shared_ptr<WsComponent>> _comps_list;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RtWsEntity();
|
explicit RtWsEntity();
|
||||||
|
@ -52,7 +52,7 @@ public:
|
||||||
/// 为本实例添加指定类型的插件
|
/// 为本实例添加指定类型的插件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ins"></param>
|
/// <param name="ins"></param>
|
||||||
virtual void append(std::shared_ptr<WsSpecializedSystem> ins) override;
|
virtual void append(std::shared_ptr<WsComponent> ins) override;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除指定类型的插件实例
|
/// 移除指定类型的插件实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
/// 获取本实例内包含的所有插件实例
|
/// 获取本实例内包含的所有插件实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
virtual QList<std::shared_ptr<WsSpecializedSystem>> components() const override;
|
virtual QList<std::shared_ptr<WsComponent>> components() const override;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 深度克隆本实例,插件和数据一致
|
/// 深度克隆本实例,插件和数据一致
|
||||||
|
@ -101,14 +101,14 @@ class SIMSBASIC_EXPORT RtEntityManager : public WsEntity, public ComponentSet,
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint64_t const_id = 0x01ff;
|
static const uint64_t const_id = 0x01ff;
|
||||||
QHash<QString, std::shared_ptr<WsSpecializedSystem>> _comps_list;
|
QHash<QString, std::shared_ptr<WsComponent>> _comps_list;
|
||||||
|
|
||||||
QString templetName() const override;
|
QString templetName() const override;
|
||||||
uint64_t entityID() const override;
|
uint64_t entityID() const override;
|
||||||
QString name() const override;
|
QString name() const override;
|
||||||
void append(std::shared_ptr<WsSpecializedSystem> ins) override;
|
void append(std::shared_ptr<WsComponent> ins) override;
|
||||||
void remove(const QString& component_type) override;
|
void remove(const QString& component_type) override;
|
||||||
QList<std::shared_ptr<WsSpecializedSystem>> components() const override;
|
QList<std::shared_ptr<WsComponent>> components() const override;
|
||||||
|
|
||||||
std::shared_ptr<Serializable> newDefault() const override;
|
std::shared_ptr<Serializable> newDefault() const override;
|
||||||
QList<WsRespondEntry> getRespondWithSignature(const WsRespondSignatureType& t) const override;
|
QList<WsRespondEntry> getRespondWithSignature(const WsRespondSignatureType& t) const override;
|
||||||
|
@ -123,7 +123,7 @@ class SIMSBASIC_EXPORT RtResourceManager : public WsEntity, public ComponentSet,
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint64_t const_id = 0x01f0;
|
static const uint64_t const_id = 0x01f0;
|
||||||
QHash<QString, std::shared_ptr<WsSpecializedSystem>> _comps_list;
|
QHash<QString, std::shared_ptr<WsComponent>> _comps_list;
|
||||||
|
|
||||||
QString templetName() const override;
|
QString templetName() const override;
|
||||||
uint64_t entityID() const override;
|
uint64_t entityID() const override;
|
||||||
|
@ -136,8 +136,8 @@ public:
|
||||||
void recoveryFrom(const QJsonObject& obj) override;
|
void recoveryFrom(const QJsonObject& obj) override;
|
||||||
void saveTo(QJsonObject& obj) const override;
|
void saveTo(QJsonObject& obj) const override;
|
||||||
|
|
||||||
void append(std::shared_ptr<WsSpecializedSystem> ins) override;
|
void append(std::shared_ptr<WsComponent> ins) override;
|
||||||
void remove(const QString& component_type) override;
|
void remove(const QString& component_type) override;
|
||||||
QList<std::shared_ptr<WsSpecializedSystem>> components() const override;
|
QList<std::shared_ptr<WsComponent>> components() const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,3 +9,14 @@ QString UniException::content() const noexcept
|
||||||
{
|
{
|
||||||
return _error_store;
|
return _error_store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "internal_impl.h"
|
||||||
|
uint64_t PublicTable::entityManagerAddress()
|
||||||
|
{
|
||||||
|
return RtEntityManager::const_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t PublicTable::resourceManagerAddress()
|
||||||
|
{
|
||||||
|
return RtResourceManager::const_id;
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
virtual QString content() const noexcept;
|
virtual QString content() const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// =======================================================
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可序列化对象
|
/// 可序列化对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -54,18 +56,6 @@ public:
|
||||||
virtual QString topicString() const = 0;
|
virtual QString topicString() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 特殊用途的数据
|
|
||||||
/// </summary>
|
|
||||||
class WsSpecializedData : public TopicData {
|
|
||||||
public:
|
|
||||||
/// <summary>
|
|
||||||
/// 内存尺寸
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
virtual uint32_t inMemSize() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通用消息基类
|
/// 通用消息基类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -83,6 +73,7 @@ public:
|
||||||
/// <returns>ID</returns>
|
/// <returns>ID</returns>
|
||||||
virtual uint64_t sourceEntity() const = 0;
|
virtual uint64_t sourceEntity() const = 0;
|
||||||
};
|
};
|
||||||
|
// ================================================================
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Respond签名类型
|
/// Respond签名类型
|
||||||
|
@ -97,6 +88,23 @@ using WsRequestSignatureType = std::pair<QString, QString>;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
using WsRespondEntry = std::function<void(std::shared_ptr<const WsMessage>, QList<std::shared_ptr<WsMessage>>&)>;
|
using WsRespondEntry = std::function<void(std::shared_ptr<const WsMessage>, QList<std::shared_ptr<WsMessage>>&)>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对外开放地址表
|
||||||
|
/// </summary>
|
||||||
|
struct PublicTable {
|
||||||
|
/// <summary>
|
||||||
|
/// 实体管理器地址
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
static uint64_t entityManagerAddress();
|
||||||
|
/// <summary>
|
||||||
|
/// 资源管理器地址
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
static uint64_t resourceManagerAddress();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 实体抽象接口
|
/// 实体抽象接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -135,16 +143,12 @@ public:
|
||||||
virtual QList<WsRespondEntry> getRespondWithInType(const QString& msg_type) const = 0;
|
virtual QList<WsRespondEntry> getRespondWithInType(const QString& msg_type) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 功能插件的基类
|
/// 功能插件的基类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class WsSpecializedSystem : public Serializable, public std::enable_shared_from_this<WsSpecializedSystem> {
|
class WsComponent : public Serializable, public std::enable_shared_from_this<WsComponent> {
|
||||||
public:
|
public:
|
||||||
/// <summary>
|
|
||||||
/// 针对指定数据Topic
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
virtual QString bindDataTopic() const = 0;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 插件唯一命名
|
/// 插件唯一命名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -156,12 +160,6 @@ public:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity_id">实体实例</param>
|
/// <param name="entity_id">实体实例</param>
|
||||||
virtual void bindEntity(std::weak_ptr<WsEntity> host) = 0;
|
virtual void bindEntity(std::weak_ptr<WsEntity> host) = 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 允许发送的消息类型签名
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
virtual QList<WsRequestSignatureType> requestSignatures() const = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 允许响应处理的消息签名类型
|
/// 允许响应处理的消息签名类型
|
||||||
|
@ -181,7 +179,6 @@ public:
|
||||||
/// <returns>处理接口列表</returns>
|
/// <returns>处理接口列表</returns>
|
||||||
virtual QList<WsRespondEntry> getRespondWithInType(const QString& msg_type) const = 0;
|
virtual QList<WsRespondEntry> getRespondWithInType(const QString& msg_type) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组件管理接口
|
/// 组件管理接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -191,7 +188,7 @@ public:
|
||||||
/// 为本实例添加指定类型的插件
|
/// 为本实例添加指定类型的插件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ins"></param>
|
/// <param name="ins"></param>
|
||||||
virtual void append(std::shared_ptr<WsSpecializedSystem> ins) = 0;
|
virtual void append(std::shared_ptr<WsComponent> ins) = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 移除指定类型的插件实例
|
/// 移除指定类型的插件实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -201,5 +198,34 @@ public:
|
||||||
/// 获取本实例内包含的所有插件实例
|
/// 获取本实例内包含的所有插件实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
virtual QList<std::shared_ptr<WsSpecializedSystem>> components() const = 0;
|
virtual QList<std::shared_ptr<WsComponent>> components() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量处理单元通用接口
|
||||||
|
/// </summary>
|
||||||
|
using WsBatchRespondEntry = std::function<void(const QList<std::shared_ptr<const WsMessage>>&, const QList<std::shared_ptr<WsEntity>>&, QList<std::shared_ptr<WsMessage>>&)>;
|
||||||
|
/// <summary>
|
||||||
|
/// 批量处理拓展
|
||||||
|
/// </summary>
|
||||||
|
class WsBatchComponent : public Serializable, public std::enable_shared_from_this<WsBatchComponent>{
|
||||||
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// 插件唯一命名
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>插件名</returns>
|
||||||
|
virtual QString name() const = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 允许响应处理的消息签名类型
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>消息签名类型集合</returns>
|
||||||
|
virtual QList<WsRespondSignatureType> respondSignatures() const = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 通过输入消息类型获取处理入口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="msg_type">输入消息类型</param>
|
||||||
|
/// <returns>处理接口列表</returns>
|
||||||
|
virtual QList<WsBatchRespondEntry> getRespondWithInType(const QString& msg_type) const = 0;
|
||||||
|
};
|
|
@ -4,33 +4,20 @@
|
||||||
ActionNodeConfiguration::ActionNodeConfiguration(QWidget* p)
|
ActionNodeConfiguration::ActionNodeConfiguration(QWidget* p)
|
||||||
:QFrame(p),
|
:QFrame(p),
|
||||||
_execute_select(new QComboBox(this)),
|
_execute_select(new QComboBox(this)),
|
||||||
_variables_input(new QTableView(this)),
|
_vars_configuration(new VariablesConfigurationPanel(this))
|
||||||
_input_model(new QStandardItemModel(this)),
|
|
||||||
_variables_output(new QTableView(this)),
|
|
||||||
_output_model(new QStandardItemModel(this))
|
|
||||||
{
|
{
|
||||||
this->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
this->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
||||||
auto p_layout = new QGridLayout(this);
|
auto p_layout = new QGridLayout(this);
|
||||||
|
|
||||||
p_layout->addWidget(new QLabel(u8"执行器类型:", this));
|
p_layout->addWidget(new QLabel(u8"执行器类型:", this));
|
||||||
p_layout->addWidget(_execute_select, 0, 1, 1, 4);
|
p_layout->addWidget(_execute_select, 0, 1, 1, 4);
|
||||||
auto vars_tabw = new QTabWidget(this);
|
p_layout->addWidget(_vars_configuration, 1, 0, 3, 5);
|
||||||
p_layout->addWidget(vars_tabw, 1, 0, 3, 5);
|
|
||||||
vars_tabw->setTabPosition(QTabWidget::West);
|
|
||||||
|
|
||||||
vars_tabw->addTab(_variables_input, u8"输入变量");
|
|
||||||
_variables_input->setModel(_input_model);
|
|
||||||
vars_tabw->addTab(_variables_output, u8"输出变量");
|
|
||||||
_variables_output->setModel(_output_model);
|
|
||||||
|
|
||||||
p_layout->setColumnStretch(1, 1);
|
p_layout->setColumnStretch(1, 1);
|
||||||
|
|
||||||
_input_model->setHorizontalHeaderLabels(QStringList()
|
|
||||||
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型"<< u8"关联输入序列" );
|
|
||||||
_output_model->setHorizontalHeaderLabels(QStringList()
|
|
||||||
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型"<< u8"关联目标变量" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "BehaviorEditor.h"
|
||||||
void ActionNodeConfiguration::setTarget(NodePresent* ins)
|
void ActionNodeConfiguration::setTarget(NodePresent* ins)
|
||||||
{
|
{
|
||||||
|
this->_vars_configuration->bindNode(ins->logicalBind());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,16 @@
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <qstandarditemmodel.h>
|
#include <qstandarditemmodel.h>
|
||||||
#include "sims_world.h"
|
#include "sims_world.h"
|
||||||
|
#include "VariablesConfiguration.h"
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 动作执行节点配置面板
|
||||||
|
/// </summary>
|
||||||
class ActionNodeConfiguration : public QFrame, public NodeConfiguration
|
class ActionNodeConfiguration : public QFrame, public NodeConfiguration
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
QComboBox *const _execute_select;
|
QComboBox *const _execute_select;
|
||||||
QTableView* const _variables_input;
|
VariablesConfigurationPanel *const _vars_configuration;
|
||||||
QStandardItemModel *const _input_model;
|
|
||||||
QTableView* const _variables_output;
|
|
||||||
QStandardItemModel* const _output_model;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionNodeConfiguration(QWidget *p = nullptr);
|
ActionNodeConfiguration(QWidget *p = nullptr);
|
||||||
|
|
|
@ -2,15 +2,26 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QStackedWidget>
|
||||||
|
#include "VariablesConfiguration.h"
|
||||||
|
|
||||||
BehaviorMapConfigurationPanel::BehaviorMapConfigurationPanel(QWidget* p)
|
BehaviorMapConfigurationPanel::BehaviorMapConfigurationPanel(QWidget* p)
|
||||||
:QFrame(p),
|
:QFrame(p),
|
||||||
|
_stacked_widget(new QStackedWidget(this)),
|
||||||
_root_name(new QLineEdit(this)),
|
_root_name(new QLineEdit(this)),
|
||||||
|
_select_map(new QComboBox(this)),
|
||||||
_variable_table(new QTableView(this)),
|
_variable_table(new QTableView(this)),
|
||||||
_variable_model(new QStandardItemModel(this))
|
_variable_model(new QStandardItemModel(this)),
|
||||||
|
_output_panel(new VariablesConfigurationPanel(this))
|
||||||
{
|
{
|
||||||
setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
|
||||||
auto p_layout = new QGridLayout(this);
|
auto vlayout = new QVBoxLayout(this);
|
||||||
|
vlayout->addWidget(_stacked_widget);
|
||||||
|
|
||||||
|
// 内部变量编辑面板
|
||||||
|
auto internal_edit = new QWidget(this);
|
||||||
|
_stacked_widget->addWidget(internal_edit);
|
||||||
|
auto p_layout = new QGridLayout(internal_edit);
|
||||||
p_layout->addWidget(new QLabel(u8"行为树名称:", this));
|
p_layout->addWidget(new QLabel(u8"行为树名称:", this));
|
||||||
p_layout->addWidget(_root_name, 0, 1, 1, 3);
|
p_layout->addWidget(_root_name, 0, 1, 1, 3);
|
||||||
|
|
||||||
|
@ -25,12 +36,19 @@ BehaviorMapConfigurationPanel::BehaviorMapConfigurationPanel(QWidget* p)
|
||||||
<< u8"输入/输出" << u8"变量名" << u8"变量类型");
|
<< u8"输入/输出" << u8"变量名" << u8"变量类型");
|
||||||
|
|
||||||
p_layout->setColumnStretch(1, 1);
|
p_layout->setColumnStretch(1, 1);
|
||||||
|
|
||||||
|
|
||||||
connect(addVar, &QPushButton::clicked, [=](){
|
connect(addVar, &QPushButton::clicked, [=](){
|
||||||
VariableAdd dia(this->_bind_node, this);
|
VariableAdd dia(this->_bind_node, this);
|
||||||
dia.exec();
|
dia.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 外部变量编辑面板
|
||||||
|
auto outlinks_edit = new QWidget(this);
|
||||||
|
_stacked_widget->addWidget(outlinks_edit);
|
||||||
|
p_layout = new QGridLayout(outlinks_edit);
|
||||||
|
p_layout->addWidget(new QLabel(u8"行为树名称:", this));
|
||||||
|
p_layout->addWidget(_select_map, 0, 1, 1, 3);
|
||||||
|
p_layout->addWidget(_output_panel, 1, 0, 3, 4);
|
||||||
|
p_layout->setColumnStretch(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <BehaviorEditor.h>
|
#include <BehaviorEditor.h>
|
||||||
|
@ -38,47 +56,56 @@ void BehaviorMapConfigurationPanel::setTarget(NodePresent* ins)
|
||||||
{
|
{
|
||||||
this->_bind_graph = ins;
|
this->_bind_graph = ins;
|
||||||
this->_bind_node = std::dynamic_pointer_cast<BehaviorMapNode>(ins->logicalBind());
|
this->_bind_node = std::dynamic_pointer_cast<BehaviorMapNode>(ins->logicalBind());
|
||||||
_variable_model->removeRows(0, _variable_model->rowCount());
|
|
||||||
|
|
||||||
_root_name->setText(_bind_node->typeName());
|
if (this->_bind_node && !this->_bind_node->bindMap()) {
|
||||||
for (auto key : _bind_node->inputVariableKeys()) {
|
_stacked_widget->setCurrentIndex(0);
|
||||||
auto ins_prop = _bind_node->getVariable(key);
|
_variable_model->removeRows(0, _variable_model->rowCount());
|
||||||
QList<QStandardItem*> row;
|
|
||||||
row << new QStandardItem(u8"ĘäČë");
|
|
||||||
row << new QStandardItem(key);
|
|
||||||
row << new QStandardItem(ins_prop->topicString());
|
|
||||||
std::for_each(row.begin(), row.end(),
|
|
||||||
[](QStandardItem* ins) {ins->setEditable(false); }
|
|
||||||
);
|
|
||||||
|
|
||||||
_variable_model->appendRow(row);
|
_root_name->setText(_bind_node->typeName());
|
||||||
|
for (auto key : _bind_node->inputVariableKeys()) {
|
||||||
|
auto ins_prop = _bind_node->getVariable(key);
|
||||||
|
QList<QStandardItem*> row;
|
||||||
|
row << new QStandardItem(u8"输入");
|
||||||
|
row << new QStandardItem(key);
|
||||||
|
row << new QStandardItem(ins_prop->topicString());
|
||||||
|
std::for_each(row.begin(), row.end(),
|
||||||
|
[](QStandardItem* ins) {ins->setEditable(false); }
|
||||||
|
);
|
||||||
|
|
||||||
|
_variable_model->appendRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto key : _bind_node->outputVariableKeys()) {
|
||||||
|
auto ins_prop = _bind_node->getVariable(key);
|
||||||
|
QList<QStandardItem*> row;
|
||||||
|
row << new QStandardItem(u8"输出");
|
||||||
|
row << new QStandardItem(key);
|
||||||
|
row << new QStandardItem(ins_prop->topicString());
|
||||||
|
std::for_each(row.begin(), row.end(),
|
||||||
|
[](QStandardItem* ins) { ins->setEditable(false); }
|
||||||
|
);
|
||||||
|
|
||||||
|
_variable_model->appendRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto key : _bind_node->internalVariableKeys()) {
|
||||||
|
auto ins_prop = _bind_node->getVariable(key);
|
||||||
|
QList<QStandardItem*> row;
|
||||||
|
row << new QStandardItem(u8"内部");
|
||||||
|
row << new QStandardItem(key);
|
||||||
|
row << new QStandardItem(ins_prop->topicString());
|
||||||
|
std::for_each(row.begin(), row.end(),
|
||||||
|
[](QStandardItem* ins) {ins->setEditable(false); }
|
||||||
|
);
|
||||||
|
|
||||||
|
_variable_model->appendRow(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this->_bind_node) {
|
||||||
|
_stacked_widget->setCurrentIndex(1);
|
||||||
|
this->_output_panel->bindNode(this->_bind_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto key : _bind_node->outputVariableKeys()) {
|
|
||||||
auto ins_prop = _bind_node->getVariable(key);
|
|
||||||
QList<QStandardItem*> row;
|
|
||||||
row << new QStandardItem(u8"Ęäłö");
|
|
||||||
row << new QStandardItem(key);
|
|
||||||
row << new QStandardItem(ins_prop->topicString());
|
|
||||||
std::for_each(row.begin(), row.end(),
|
|
||||||
[](QStandardItem* ins) { ins->setEditable(false); }
|
|
||||||
);
|
|
||||||
|
|
||||||
_variable_model->appendRow(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto key : _bind_node->internalVariableKeys()) {
|
|
||||||
auto ins_prop = _bind_node->getVariable(key);
|
|
||||||
QList<QStandardItem*> row;
|
|
||||||
row << new QStandardItem(u8"ÄÚ˛ż");
|
|
||||||
row << new QStandardItem(key);
|
|
||||||
row << new QStandardItem(ins_prop->topicString());
|
|
||||||
std::for_each(row.begin(), row.end(),
|
|
||||||
[](QStandardItem* ins) {ins->setEditable(false); }
|
|
||||||
);
|
|
||||||
|
|
||||||
_variable_model->appendRow(row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableAdd::VariableAdd(std::shared_ptr<BehaviorMapNode> node, QWidget* parent)
|
VariableAdd::VariableAdd(std::shared_ptr<BehaviorMapNode> node, QWidget* parent)
|
||||||
|
|
|
@ -24,14 +24,21 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class NodePresent;
|
class NodePresent;
|
||||||
|
class VariablesConfigurationPanel;
|
||||||
|
#include <QStackedWidget>
|
||||||
class BehaviorMapConfigurationPanel : public QFrame, public NodeConfiguration
|
class BehaviorMapConfigurationPanel : public QFrame, public NodeConfiguration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
QStackedWidget *const _stacked_widget;
|
||||||
|
|
||||||
QLineEdit *const _root_name;
|
QLineEdit *const _root_name;
|
||||||
|
QComboBox *const _select_map;
|
||||||
QTableView *const _variable_table;
|
QTableView *const _variable_table;
|
||||||
QStandardItemModel *const _variable_model;
|
QStandardItemModel *const _variable_model;
|
||||||
|
|
||||||
|
VariablesConfigurationPanel *const _output_panel;
|
||||||
|
|
||||||
std::shared_ptr<BehaviorMapNode> _bind_node; // 绑定内容结点
|
std::shared_ptr<BehaviorMapNode> _bind_node; // 绑定内容结点
|
||||||
NodePresent *_bind_graph = nullptr; // 绑定图形显示结点
|
NodePresent *_bind_graph = nullptr; // 绑定图形显示结点
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
<ClCompile Include="ModifyNodeConfiguration.cpp" />
|
<ClCompile Include="ModifyNodeConfiguration.cpp" />
|
||||||
<ClCompile Include="PerspectiveView.cpp" />
|
<ClCompile Include="PerspectiveView.cpp" />
|
||||||
<ClCompile Include="TempletAssemble.cpp" />
|
<ClCompile Include="TempletAssemble.cpp" />
|
||||||
|
<ClCompile Include="VariablesConfiguration.cpp" />
|
||||||
<QtRcc Include="sims_world.qrc" />
|
<QtRcc Include="sims_world.qrc" />
|
||||||
<QtUic Include="sims_world.ui" />
|
<QtUic Include="sims_world.ui" />
|
||||||
<QtMoc Include="sims_world.h" />
|
<QtMoc Include="sims_world.h" />
|
||||||
|
@ -124,6 +125,7 @@
|
||||||
<ClInclude Include="ActionNodeConfiguration.h" />
|
<ClInclude Include="ActionNodeConfiguration.h" />
|
||||||
<ClInclude Include="CompareNodeConfiguration.h" />
|
<ClInclude Include="CompareNodeConfiguration.h" />
|
||||||
<ClInclude Include="ModifyNodeConfiguration.h" />
|
<ClInclude Include="ModifyNodeConfiguration.h" />
|
||||||
|
<ClInclude Include="VariablesConfiguration.h" />
|
||||||
<QtMoc Include="BehaviorConfigurationPanel.h" />
|
<QtMoc Include="BehaviorConfigurationPanel.h" />
|
||||||
<QtMoc Include="BehaviorEditor.h" />
|
<QtMoc Include="BehaviorEditor.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
<ClCompile Include="ModifyNodeConfiguration.cpp">
|
<ClCompile Include="ModifyNodeConfiguration.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="VariablesConfiguration.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="TempletAssemble.h">
|
<QtMoc Include="TempletAssemble.h">
|
||||||
|
@ -92,5 +95,8 @@
|
||||||
<ClInclude Include="ModifyNodeConfiguration.h">
|
<ClInclude Include="ModifyNodeConfiguration.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="VariablesConfiguration.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include "VariablesConfiguration.h"
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
|
VariablesConfigurationPanel::VariablesConfigurationPanel(QWidget* p /*= nullptr*/)
|
||||||
|
:QWidget(p),
|
||||||
|
_input_vars_model(new QStandardItemModel(this)),
|
||||||
|
_output_vars_model(new QStandardItemModel(this)),
|
||||||
|
_input_table(new QTableView(this)),
|
||||||
|
_output_table(new QTableView(this))
|
||||||
|
{
|
||||||
|
auto vbox = new QVBoxLayout(this);
|
||||||
|
|
||||||
|
auto tabw = new QTabWidget(this);
|
||||||
|
vbox->addWidget(tabw);
|
||||||
|
|
||||||
|
tabw->addTab(_input_table, u8"输入变量");
|
||||||
|
tabw->addTab(_output_table, u8"输出变量");
|
||||||
|
tabw->setTabPosition(QTabWidget::West);
|
||||||
|
|
||||||
|
vbox->setMargin(0);
|
||||||
|
_input_table->setModel(_input_vars_model);
|
||||||
|
_output_table->setModel(_output_vars_model);
|
||||||
|
_input_vars_model->setHorizontalHeaderLabels(QStringList()
|
||||||
|
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型" << u8"关联输入序列");
|
||||||
|
_output_vars_model->setHorizontalHeaderLabels(QStringList()
|
||||||
|
<< u8"变量名" << u8"变量类型" << u8"关联转换器类型" << u8"关联目标变量");
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
void VariablesConfigurationPanel::bindNode(std::shared_ptr<LogicalNode> inst)
|
||||||
|
{
|
||||||
|
this->_active_node = inst;
|
||||||
|
|
||||||
|
qDebug() << __FILE__ << __LINE__ << inst->rtName();
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
#include <QTableView>
|
||||||
|
#include <BehaviorPerform.h>
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ½Úµã±äÁ¿ÅäÖÃÃæ°å
|
||||||
|
/// </summary>
|
||||||
|
class VariablesConfigurationPanel : public QWidget
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
QStandardItemModel* const _input_vars_model;
|
||||||
|
QStandardItemModel* const _output_vars_model;
|
||||||
|
QTableView *const _input_table;
|
||||||
|
QTableView *const _output_table;
|
||||||
|
|
||||||
|
std::shared_ptr<LogicalNode> _active_node = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VariablesConfigurationPanel(QWidget *p = nullptr);
|
||||||
|
|
||||||
|
void bindNode(std::shared_ptr<LogicalNode> inst);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue