69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
#include "ComponentsInfoPull.h"
|
|
|
|
ComponentsInfoPull::ComponentsInfoPull() {}
|
|
|
|
void ComponentsInfoPull::bindEntity(std::weak_ptr<WsEntity> ins)
|
|
{
|
|
this->_bind_entity = ins;
|
|
}
|
|
|
|
QString ComponentsInfoPull::name() const
|
|
{
|
|
return NAME(ComponentsInfoPull);
|
|
}
|
|
|
|
#include <QVariant>
|
|
#include <QJsonArray>
|
|
void ComponentsInfoPull::execute(
|
|
std::shared_ptr<const ComponentDatasQuery> in, QList<std::shared_ptr<ComponentDatasQueryResult>>& out)
|
|
{
|
|
auto rst = std::make_shared<ComponentDatasQueryResult>();
|
|
rst->reset(in->targetEntity(), in->sourceEntity());
|
|
|
|
auto bind_e = this->_bind_entity.lock();
|
|
rst->_entity_json["entity_templet"] = bind_e->templetName();
|
|
rst->_entity_json["entity_id"] = QJsonValue::fromVariant(QVariant::fromValue(bind_e->entityID()));
|
|
rst->_entity_json["entity_name"] = bind_e->name();
|
|
|
|
QList<std::shared_ptr<WsSpecializedSystem>> comp_list;
|
|
auto host_conv = std::dynamic_pointer_cast<ComponentSet>(bind_e);
|
|
comp_list = host_conv->components();
|
|
|
|
auto array = QJsonArray();
|
|
for (auto ins : comp_list) {
|
|
if(ins->name() == this->name())
|
|
continue;
|
|
|
|
auto info_comp = QJsonObject();
|
|
info_comp["component_type"] = ins->name();
|
|
ins->saveTo(info_comp);
|
|
array.append(info_comp);
|
|
}
|
|
rst->_entity_json["component_list"] = array;
|
|
out << rst;
|
|
}
|
|
|
|
#include <internal_impl.h>
|
|
void ComponentsInfoPull::execute(
|
|
std::shared_ptr<const ProcedureSignatureQuery> in, QList<std::shared_ptr<ProcedureSignatureQueryResult>>& out)
|
|
{
|
|
auto ent_ins = std::dynamic_pointer_cast<ComponentSet>(this->_bind_entity.lock());
|
|
auto comps = ent_ins->components();
|
|
|
|
auto result = std::make_shared<ProcedureSignatureQueryResult>();
|
|
result->reset(in->targetEntity(), in->sourceEntity());
|
|
for (auto cp : comps) {
|
|
result->_signature_list.append(cp->respondSignatures());
|
|
}
|
|
out << result;
|
|
}
|
|
|
|
std::shared_ptr<Serializable> ComponentsInfoPull::newDefault() const
|
|
{
|
|
return std::make_shared<ComponentsInfoPull>();
|
|
}
|
|
|
|
void ComponentsInfoPull::recoveryFrom(const QJsonObject& obj) {}
|
|
|
|
void ComponentsInfoPull::saveTo(QJsonObject& obj) const {}
|