basic-framework
This commit is contained in:
parent
ed6371a19f
commit
35101bb2f5
|
@ -101,12 +101,15 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="componentbasic.cpp" />
|
||||
<ClCompile Include="EntityDocks.cpp" />
|
||||
<ClCompile Include="invisible_component.cpp" />
|
||||
<ClCompile Include="MapRoute.cpp" />
|
||||
<ClCompile Include="VisibleBox.cpp" />
|
||||
<ClInclude Include="componentbasic_global.h" />
|
||||
<ClInclude Include="componentbasic.h" />
|
||||
<QtMoc Include="EntityDocks.h" />
|
||||
<ClInclude Include="invisible_component.h" />
|
||||
<ClInclude Include="MapRoute.h" />
|
||||
<ClInclude Include="VisibleBox.h" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
<ClInclude Include="MapRoute.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="invisible_component.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="VisibleBox.cpp">
|
||||
|
@ -46,6 +49,12 @@
|
|||
<ClCompile Include="EntityDocks.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="componentbasic.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="invisible_component.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="EntityDocks.h">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "EntityDocks.h"
|
||||
#include <stdexcept>
|
||||
|
||||
QList<std::shared_ptr<WsMessage>> deduct_each(std::shared_ptr<WsEntity> item)
|
||||
QList<std::shared_ptr<WsMessage>> deduct_each(std::shared_ptr<WsEntity> item)
|
||||
{
|
||||
QList<std::shared_ptr<WsMessage>> rets;
|
||||
auto immediate = std::make_shared<ImmediateCore>(item);
|
||||
|
@ -30,7 +30,7 @@ void DeduceFramework::deduceBegin(std::shared_ptr<const DeduceRequest> ins)
|
|||
auto dt = QTime::currentTime();
|
||||
|
||||
auto ret_list_set = QtConcurrent::blockingMapped(
|
||||
_entity_map.values(), deduct_each
|
||||
_entity_map_over_0xffff.values(), deduct_each
|
||||
);
|
||||
|
||||
_accept_stack.clear();
|
||||
|
@ -44,10 +44,17 @@ void DeduceFramework::deduceBegin(std::shared_ptr<const DeduceRequest> ins)
|
|||
}
|
||||
|
||||
#include <simsbasic.h>
|
||||
DeduceFramework::DeduceFramework() {
|
||||
#include "invisible_component.h"
|
||||
DeduceFramework::DeduceFramework()
|
||||
:_factory_ins(std::make_shared<ComponentFactory>()) {
|
||||
}
|
||||
|
||||
void DeduceFramework::init_backend()
|
||||
{
|
||||
auto mgr_e = std::make_shared<EntitiesManager>();
|
||||
mgr_e->append(this->shared_from_this());
|
||||
this->_entity_map[mgr_e->entityID()] = mgr_e;
|
||||
|
||||
this->_entity_map_over_0xffff[mgr_e->entityID()] = mgr_e;
|
||||
}
|
||||
|
||||
std::shared_ptr<WsComponent> DeduceFramework::defaultNew() const
|
||||
|
@ -55,9 +62,9 @@ std::shared_ptr<WsComponent> DeduceFramework::defaultNew() const
|
|||
throw std::logic_error("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
void DeduceFramework::bindEntity(uint64_t entity_id)
|
||||
void DeduceFramework::bindEntity(std::weak_ptr<WsEntity> ins)
|
||||
{
|
||||
this->_bind_entity = entity_id;
|
||||
this->_bind_entity = ins;
|
||||
}
|
||||
|
||||
QString DeduceFramework::name() const
|
||||
|
@ -76,15 +83,255 @@ void DeduceFramework::saveTo(QJsonObject& obj) const
|
|||
}
|
||||
|
||||
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||
std::shared_ptr<const EntityAllocte> in, QList<std::shared_ptr<RespondDefault>>& out)
|
||||
std::shared_ptr<const EntityOperate> in, QList<std::shared_ptr<RespondDefault>>& out)
|
||||
{
|
||||
auto dt = QTime::currentTime();
|
||||
|
||||
auto result = std::make_shared<RespondDefault>();
|
||||
result->reset(in->targetEntity(), in->sourceEntity());
|
||||
|
||||
switch ((EntityOperateType)in->_operate_code)
|
||||
{
|
||||
case EntityOperateType::NEW: {
|
||||
if (!this->_templets_within_0x2ff_0xffff.contains(in->_template_name)) {
|
||||
result->_reason_text = QString("指定的Template:%1不存在").arg(in->_template_name);
|
||||
}
|
||||
else {
|
||||
result->_success_mark = true;
|
||||
|
||||
auto ins_t = this->_templets_within_0x2ff_0xffff[in->_template_name];
|
||||
auto new_copy = std::static_pointer_cast<RtEntity>(ins_t->defaultNew());
|
||||
new_copy->resetID(0xffff);
|
||||
auto desc_p = std::make_shared<ComponentsInfoPull>();
|
||||
new_copy->append(desc_p);
|
||||
|
||||
while (_entity_map_over_0xffff.contains(new_copy->entityID()))
|
||||
{
|
||||
auto ncode = new_copy->entityID() + 1;
|
||||
new_copy->resetID(ncode);
|
||||
}
|
||||
_entity_map_over_0xffff[new_copy->entityID()] = new_copy;
|
||||
}
|
||||
}break;
|
||||
case EntityOperateType::DELETE: {
|
||||
if (!this->_entity_map_over_0xffff.contains(in->_entity_id_over_0xffff)) {
|
||||
result->_reason_text = QString("指定的实体id:%1不存在").arg(in->_entity_id_over_0xffff);
|
||||
}
|
||||
else {
|
||||
result->_success_mark = true;
|
||||
this->_entity_map_over_0xffff.remove(in->_entity_id_over_0xffff);
|
||||
}
|
||||
}break;
|
||||
case EntityOperateType::MODIFY: {
|
||||
if (!this->_entity_map_over_0xffff.contains(in->_entity_id_over_0xffff)) {
|
||||
result->_reason_text = QString("指定的实体id:%1不存在").arg(in->_entity_id_over_0xffff);
|
||||
}
|
||||
else {
|
||||
result->_success_mark = true;
|
||||
|
||||
auto target_ins = std::static_pointer_cast<RtEntity>(
|
||||
this->_entity_map_over_0xffff[in->_entity_id_over_0xffff]
|
||||
);
|
||||
target_ins->resetName(in->_entity_name);
|
||||
target_ins->resetTemplet(in->_template_name);
|
||||
}
|
||||
}break;
|
||||
default:
|
||||
result->_reason_text = QString("指定操作码非法:%1").arg(in->_operate_code);
|
||||
break;
|
||||
}
|
||||
|
||||
result->_time_consume = dt.msecsTo(QTime::currentTime());
|
||||
out << result;
|
||||
}
|
||||
|
||||
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||
std::shared_ptr<const EntityTotalGet> in, QList<std::shared_ptr<EntityTotalList>>& out)
|
||||
{
|
||||
auto rst = std::make_shared<EntityTotalList>();
|
||||
rst->reset(in->targetEntity(), in->sourceEntity());
|
||||
rst->_entities_list = _entity_map.keys();
|
||||
rst->_entities_list = _entity_map_over_0xffff.keys();
|
||||
out << rst;
|
||||
}
|
||||
|
||||
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||
std::shared_ptr<const TypesQuery> in, QList<std::shared_ptr<TypesQueryResult>>& out)
|
||||
{
|
||||
auto ins = std::make_shared<TypesQueryResult>();
|
||||
ins->reset(in->targetEntity(), in->sourceEntity());
|
||||
ins->_component_types = this->_factory_ins->allComponentTypes();
|
||||
for (auto ekey : this->_templets_within_0x2ff_0xffff.keys())
|
||||
ins->_entity_templets[ekey] = this->_templets_within_0x2ff_0xffff[ekey]->entityID();
|
||||
|
||||
out << ins;
|
||||
}
|
||||
|
||||
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||
std::shared_ptr<const TempletOperate> in, QList<std::shared_ptr<RespondDefault>>& out)
|
||||
{
|
||||
auto dt = QTime::currentTime();
|
||||
|
||||
auto nins = std::make_shared<RespondDefault>();
|
||||
nins->reset(in->targetEntity(), in->sourceEntity());
|
||||
|
||||
switch ((EntityOperateType)in->_operate_code) {
|
||||
case EntityOperateType::NEW: {
|
||||
nins->_success_mark = true;
|
||||
auto ent_t = std::make_shared<RtEntity>();
|
||||
ent_t->resetTemplet(in->_template_name);
|
||||
auto desc_p = std::make_shared<ComponentsInfoPull>();
|
||||
ent_t->append(desc_p);
|
||||
|
||||
// 提取所有的模板id
|
||||
auto _tm_ins = _templets_within_0x2ff_0xffff.values();
|
||||
QList<uint64_t> allids;
|
||||
std::transform(_templets_within_0x2ff_0xffff.begin(),
|
||||
_templets_within_0x2ff_0xffff.end(),
|
||||
std::back_inserter(allids),
|
||||
[](std::shared_ptr<RtEntity> i) { return i->entityID(); });
|
||||
|
||||
// 重置模板id
|
||||
while (allids.contains(ent_t->entityID())) {
|
||||
auto nid = ent_t->entityID() + 1;
|
||||
ent_t->resetID(nid);
|
||||
}
|
||||
|
||||
// 模板载入系统
|
||||
_templets_within_0x2ff_0xffff[in->_template_name] = ent_t;
|
||||
}break;
|
||||
case EntityOperateType::DELETE: {
|
||||
for (auto ekey : this->_templets_within_0x2ff_0xffff.keys()) {
|
||||
auto eins = this->_templets_within_0x2ff_0xffff[ekey];
|
||||
nins->_success_mark = false;
|
||||
nins->_reason_text = QString("指定的实体id:%1不存在").arg(in->_template_id_within_0x2ff_0xffff);
|
||||
|
||||
if (eins->entityID() == in->_template_id_within_0x2ff_0xffff) {
|
||||
this->_templets_within_0x2ff_0xffff.remove(ekey);
|
||||
nins->_success_mark = true;
|
||||
nins->_reason_text = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case EntityOperateType::MODIFY: {
|
||||
for (auto ekey : this->_templets_within_0x2ff_0xffff.keys()) {
|
||||
auto eins = this->_templets_within_0x2ff_0xffff[ekey];
|
||||
nins->_reason_text = QString("指定的实体id:%1不存在").arg(in->_template_id_within_0x2ff_0xffff);
|
||||
nins->_success_mark = false;
|
||||
|
||||
if (eins->entityID() == in->_template_id_within_0x2ff_0xffff) {
|
||||
eins->resetTemplet(in->_template_name);
|
||||
nins->_success_mark = true;
|
||||
nins->_reason_text = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
default:
|
||||
nins->_reason_text = QString("指定操作码非法:%1").arg(in->_operate_code);
|
||||
break;
|
||||
}
|
||||
|
||||
nins->_time_consume = dt.msecsTo(QTime::currentTime());
|
||||
out << nins;
|
||||
}
|
||||
|
||||
void DeduceFramework::execute(std::shared_ptr<ImmediateMap> map,
|
||||
std::shared_ptr<const ComponentOperate> in, QList<std::shared_ptr<RespondDefault>>& out)
|
||||
{
|
||||
auto dt = QTime::currentTime();
|
||||
|
||||
auto result = std::make_shared<RespondDefault>();
|
||||
result->reset(in->targetEntity(), in->sourceEntity());
|
||||
|
||||
// 提取目标实例 ====================================================
|
||||
std::shared_ptr<RtEntity> target_ins = nullptr;
|
||||
if (in->_entity_id_within_0x2ff_0xffffffffffffffff < 0xffff) {
|
||||
for (auto info_t : this->_templets_within_0x2ff_0xffff) {
|
||||
if (info_t->entityID() == in->_entity_id_within_0x2ff_0xffffffffffffffff) {
|
||||
target_ins = info_t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this->_entity_map_over_0xffff.contains(in->_entity_id_within_0x2ff_0xffffffffffffffff)) {
|
||||
target_ins = std::static_pointer_cast<RtEntity>(
|
||||
this->_entity_map_over_0xffff[in->_entity_id_within_0x2ff_0xffffffffffffffff]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!target_ins) {
|
||||
result->_reason_text = QString("指定的实体id:%1不存在").arg(in->_entity_id_within_0x2ff_0xffffffffffffffff);
|
||||
}
|
||||
else {
|
||||
result->_success_mark = true;
|
||||
|
||||
QStringList total_component_types = this->_factory_ins->allComponentTypes();
|
||||
for (auto chk : in->_component_types) {
|
||||
if (!total_component_types.contains(chk)) {
|
||||
result->_success_mark = false;
|
||||
result->_reason_text = QString("ComponentType错误,包含非法类型:%1").arg(chk);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result->_success_mark) {
|
||||
auto comps_list = target_ins->components();
|
||||
|
||||
QStringList exists_component_types;
|
||||
std::transform(comps_list.begin(), comps_list.end(),
|
||||
std::back_inserter(exists_component_types),
|
||||
[](std::shared_ptr<WsComponent> c) { return c->name(); });
|
||||
|
||||
for (auto comp : in->_component_types) {
|
||||
if (!exists_component_types.contains(comp)) {
|
||||
auto ins_comp = this->_factory_ins->makeNew(comp);
|
||||
target_ins->append(ins_comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result->_time_consume = dt.msecsTo(QTime::currentTime());
|
||||
out << result;
|
||||
}
|
||||
|
||||
#include "VisibleBox.h"
|
||||
ComponentFactory::ComponentFactory()
|
||||
{
|
||||
auto ins = std::make_shared<VisibleCubePlugin>();
|
||||
_comp_types[ins->name()] = ins;
|
||||
}
|
||||
|
||||
std::shared_ptr<WsComponent> ComponentFactory::makeNew(const QString& type)
|
||||
{
|
||||
if (!this->_comp_types.contains(type))
|
||||
return NULL;
|
||||
|
||||
auto ntype = _comp_types[type];
|
||||
return ntype->defaultNew();
|
||||
}
|
||||
|
||||
QList<QString> ComponentFactory::allComponentTypes() const
|
||||
{
|
||||
return _comp_types.keys();
|
||||
}
|
||||
|
||||
void ComponentFactory::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
QStringList tlist;
|
||||
STRLIST_PEAK(tlist);
|
||||
|
||||
auto curr_list = _comp_types.keys();
|
||||
for (auto chk : tlist)
|
||||
if (!curr_list.contains(chk))
|
||||
throw std::logic_error("基础数据不兼容");
|
||||
}
|
||||
|
||||
void ComponentFactory::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
QStringList tlist = _comp_types.keys();
|
||||
std::sort(tlist.begin(), tlist.end());
|
||||
STRLIST_SAVE(tlist);
|
||||
}
|
||||
|
|
|
@ -5,16 +5,37 @@
|
|||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
class COMPONENTBASIC_EXPORT ComponentFactory : public Serializable {
|
||||
private:
|
||||
QHash<QString, std::shared_ptr<WsComponent>> _comp_types;
|
||||
|
||||
public:
|
||||
ComponentFactory();
|
||||
|
||||
std::shared_ptr<WsComponent> makeNew(const QString &type);
|
||||
QList<QString> allComponentTypes() const;
|
||||
|
||||
// ͨ¹ý Serializable ¼Ì³Ð
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
|
||||
};
|
||||
|
||||
class COMPONENTBASIC_EXPORT DeduceFramework : public QObject,
|
||||
public ProcList<
|
||||
WsRespond<EntityAllocte, RespondDefault>,
|
||||
WsRespond<TypesQuery, TypesQueryResult>,
|
||||
WsRespond<TempletOperate, RespondDefault>,
|
||||
WsRespond<EntityOperate, RespondDefault>,
|
||||
WsRespond<ComponentOperate, RespondDefault>,
|
||||
WsRespond<EntityTotalGet, EntityTotalList>>
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
uint64_t _bind_entity = 0;
|
||||
std::weak_ptr<WsEntity> _bind_entity;
|
||||
std::shared_ptr<ComponentFactory> _factory_ins;
|
||||
|
||||
QHash<uint64_t, std::shared_ptr<WsEntity>> _entity_map;
|
||||
QHash<QString, std::shared_ptr<RtEntity>> _templets_within_0x2ff_0xffff;
|
||||
QHash<uint64_t, std::shared_ptr<WsEntity>> _entity_map_over_0xffff;
|
||||
|
||||
signals:
|
||||
/// <summary>
|
||||
|
@ -42,15 +63,22 @@ public slots:
|
|||
|
||||
public:
|
||||
static QList<std::shared_ptr<WsMessage>> _accept_stack;
|
||||
|
||||
DeduceFramework();
|
||||
|
||||
void init_backend();
|
||||
|
||||
std::shared_ptr<WsComponent> defaultNew() const override;
|
||||
void bindEntity(uint64_t entity_id) override;
|
||||
void bindEntity(std::weak_ptr<WsEntity> ins) override;
|
||||
QString name() const override;
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
|
||||
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const EntityAllocte> in, QList<std::shared_ptr<RespondDefault>>& out) override;
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const TypesQuery> in, QList<std::shared_ptr<TypesQueryResult>>& out) override;
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const TempletOperate> in, QList<std::shared_ptr<RespondDefault>>& out) override;
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const EntityOperate> in, QList<std::shared_ptr<RespondDefault>>& out) override;
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const ComponentOperate> in, QList<std::shared_ptr<RespondDefault>>& out) override;
|
||||
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const EntityTotalGet> in, QList<std::shared_ptr<EntityTotalList>>& out) override;
|
||||
};
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
// ͨ¹ý ProcList ¼Ì³Ð
|
||||
|
||||
void Visible3DPlugin::recoveryFrom(const QJsonObject& obj) {
|
||||
this->_bind_entity = obj["_bind_entity"].toVariant().toULongLong();
|
||||
void VisibleCubePlugin::recoveryFrom(const QJsonObject& obj) {
|
||||
DOUOBLE_PEAK(_self_d3._length_m);
|
||||
DOUOBLE_PEAK(_self_d3._width_m);
|
||||
DOUOBLE_PEAK(_self_d3._height_m);
|
||||
|
@ -18,9 +17,7 @@ void Visible3DPlugin::recoveryFrom(const QJsonObject& obj) {
|
|||
DOUOBLE_PEAK(_self_posture._roll_deg);
|
||||
}
|
||||
|
||||
void Visible3DPlugin::saveTo(QJsonObject& obj) const {
|
||||
obj["_bind_entity"] = QJsonValue::fromVariant(QVariant::fromValue(this->_bind_entity));
|
||||
|
||||
void VisibleCubePlugin::saveTo(QJsonObject& obj) const {
|
||||
DOUBLE_SAVE(_self_d3._length_m);
|
||||
DOUBLE_SAVE(_self_d3._width_m);
|
||||
DOUBLE_SAVE(_self_d3._height_m);
|
||||
|
@ -34,8 +31,8 @@ void Visible3DPlugin::saveTo(QJsonObject& obj) const {
|
|||
DOUBLE_SAVE(_self_posture._roll_deg);
|
||||
}
|
||||
|
||||
std::shared_ptr<WsComponent> Visible3DPlugin::defaultNew() const {
|
||||
auto copy = std::make_shared<Visible3DPlugin>();
|
||||
std::shared_ptr<WsComponent> VisibleCubePlugin::defaultNew() const {
|
||||
auto copy = std::make_shared<VisibleCubePlugin>();
|
||||
copy->_bind_entity = _bind_entity;
|
||||
copy->_self_d3 = _self_d3;
|
||||
copy->_self_lla = _self_lla;
|
||||
|
@ -43,20 +40,21 @@ std::shared_ptr<WsComponent> Visible3DPlugin::defaultNew() const {
|
|||
return copy;
|
||||
}
|
||||
|
||||
void Visible3DPlugin::bindEntity(uint64_t entity_id) {
|
||||
this->_bind_entity = entity_id;
|
||||
void VisibleCubePlugin::bindEntity(std::weak_ptr<WsEntity> ins)
|
||||
{
|
||||
this->_bind_entity = ins;
|
||||
}
|
||||
|
||||
QString Visible3DPlugin::name() const {
|
||||
return NAME(Visible3DPlugin);
|
||||
QString VisibleCubePlugin::name() const {
|
||||
return NAME(VisibleCubePlugin);
|
||||
}
|
||||
|
||||
void Visible3DPlugin::execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, QList<std::shared_ptr<Box3DDesc>>& out)
|
||||
void VisibleCubePlugin::execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, QList<std::shared_ptr<Box3DDesc>>& out)
|
||||
{
|
||||
auto ins = std::make_shared<Box3DDesc>();
|
||||
ins->_lla_pos = _self_lla;
|
||||
ins->_posture_d3 = _self_posture;
|
||||
ins->_d3_data = _self_d3;
|
||||
ins->reset(_bind_entity, in->sourceEntity());
|
||||
ins->reset(in->targetEntity(), in->sourceEntity());
|
||||
out << ins;
|
||||
}
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
/// <summary>
|
||||
/// 可视化3d体积盒
|
||||
/// </summary>
|
||||
class COMPONENTBASIC_EXPORT Visible3DPlugin : public ProcList<
|
||||
class COMPONENTBASIC_EXPORT VisibleCubePlugin : public ProcList<
|
||||
WsRespond<Get3DBox, Box3DDesc>
|
||||
>
|
||||
{
|
||||
private:
|
||||
uint64_t _bind_entity = 0;
|
||||
std::weak_ptr<WsEntity> _bind_entity;
|
||||
D3Data _self_d3;
|
||||
LLAPos _self_lla;
|
||||
Posture _self_posture;
|
||||
|
||||
public:
|
||||
explicit Visible3DPlugin() = default;
|
||||
explicit VisibleCubePlugin() = default;
|
||||
|
||||
// 通过 ProcList 继承
|
||||
void bindEntity(uint64_t entity_id) override;
|
||||
void bindEntity(std::weak_ptr<WsEntity> ins) override;
|
||||
QString name() const override;
|
||||
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const Get3DBox> in, QList<std::shared_ptr<Box3DDesc>>& out) override;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#include "componentbasic.h"
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#include "invisible_component.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<ImmediateMap> map,
|
||||
std::shared_ptr<const ComponentInfosQuery> in, QList<std::shared_ptr<ComponentInfoQueryResult>>& out)
|
||||
{
|
||||
auto rst = std::make_shared<ComponentInfoQueryResult>();
|
||||
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<WsComponent>> 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
std::shared_ptr<WsComponent> ComponentsInfoPull::defaultNew() const
|
||||
{
|
||||
return std::make_shared<ComponentsInfoPull>();
|
||||
}
|
||||
|
||||
void ComponentsInfoPull::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ComponentsInfoPull::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include <messagebasic.h>
|
||||
#include "componentbasic.h"
|
||||
|
||||
class COMPONENTBASIC_EXPORT ComponentsInfoPull : public ProcList<
|
||||
WsRespond<ComponentInfosQuery, ComponentInfoQueryResult>
|
||||
> {
|
||||
private:
|
||||
std::weak_ptr<WsEntity> _bind_entity;
|
||||
|
||||
public:
|
||||
ComponentsInfoPull();
|
||||
|
||||
// ͨ¹ý ProcList ¼Ì³Ð
|
||||
void bindEntity(std::weak_ptr<WsEntity> ins) override;
|
||||
QString name() const override;
|
||||
|
||||
void execute(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const ComponentInfosQuery> in, QList<std::shared_ptr<ComponentInfoQueryResult>>& out) override;
|
||||
|
||||
std::shared_ptr<WsComponent> defaultNew() const override;
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
};
|
|
@ -40,12 +40,16 @@ void RespondDefault::recoveryFrom(const QJsonObject& obj)
|
|||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
DOUOBLE_PEAK(_time_consume);
|
||||
UINT64_PEAK(_success_mark);
|
||||
STRING_PEAK(_reason_text);
|
||||
}
|
||||
|
||||
void RespondDefault::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
DOUBLE_SAVE(_time_consume);
|
||||
UINT64_SAVE(_success_mark);
|
||||
STRING_SAVE(_reason_text);
|
||||
}
|
||||
|
||||
Get3DBox::Get3DBox()
|
||||
|
@ -90,22 +94,28 @@ void Box3DDesc::saveTo(QJsonObject& obj) const
|
|||
DOUBLE_SAVE(this->_posture_d3._roll_deg);
|
||||
}
|
||||
|
||||
EntityAllocte::EntityAllocte()
|
||||
EntityOperate::EntityOperate()
|
||||
:AbstractMessage(NAME(EntityAllocte)) {
|
||||
}
|
||||
|
||||
void EntityAllocte::recoveryFrom(const QJsonObject& obj)
|
||||
void EntityOperate::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
|
||||
STRING_PEAK(_entity_templet);
|
||||
UINT64_PEAK(_operate_code);
|
||||
STRING_PEAK(_template_name);
|
||||
STRING_PEAK(_entity_name);
|
||||
UINT64_PEAK(_entity_id_over_0xffff);
|
||||
}
|
||||
|
||||
void EntityAllocte::saveTo(QJsonObject& obj) const
|
||||
void EntityOperate::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
|
||||
STRING_SAVE(_entity_templet);
|
||||
UINT64_SAVE(_operate_code);
|
||||
STRING_SAVE(_template_name);
|
||||
STRING_SAVE(_entity_name);
|
||||
UINT64_SAVE(_entity_id_over_0xffff);
|
||||
}
|
||||
|
||||
AbstractMessage::AbstractMessage(const QString& topic) :_topic_string(topic) {}
|
||||
|
@ -169,3 +179,127 @@ void EntityTotalList::saveTo(QJsonObject& obj) const
|
|||
[](int v) { return QString(",").arg(v); });
|
||||
STRLIST_SAVE(strs);
|
||||
}
|
||||
|
||||
TypesQueryResult::TypesQueryResult()
|
||||
:AbstractMessage(NAME(TypesQueryResult)) {
|
||||
}
|
||||
|
||||
auto ilist_conv = [](const QList<uint64_t>& ilist) {
|
||||
QStringList _templets_ids;
|
||||
std::transform(ilist.begin(), ilist.end(),
|
||||
std::back_inserter(_templets_ids), [](uint64_t v) {return QString("%1").arg(v); });
|
||||
return _templets_ids;
|
||||
};
|
||||
auto ilist_from = [](const QStringList& slist) {
|
||||
QList<uint64_t> _ids;
|
||||
std::transform(slist.begin(), slist.end(),
|
||||
std::back_inserter(_ids), [](QString s) { return s.toULongLong(); });
|
||||
return _ids;
|
||||
};
|
||||
void TypesQueryResult::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
STRLIST_PEAK(_component_types);
|
||||
|
||||
QStringList _templet_types;
|
||||
STRLIST_SAVE(_templet_types);
|
||||
|
||||
QStringList _templets_ids;
|
||||
STRLIST_SAVE(_templets_ids);
|
||||
auto idlist = ilist_from(_templets_ids);
|
||||
|
||||
_entity_templets.clear();
|
||||
for (auto idx = 0; idx < _templets_ids.size(); idx++) {
|
||||
_entity_templets[_templet_types.at(idx)] = idlist.at(idx);
|
||||
}
|
||||
}
|
||||
|
||||
void TypesQueryResult::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
STRLIST_SAVE(_component_types);
|
||||
|
||||
QStringList _templet_types = _entity_templets.keys();
|
||||
STRLIST_SAVE(_templet_types);
|
||||
|
||||
QList<uint64_t> _templet_ids;
|
||||
for (auto key : _templet_types)
|
||||
_templet_ids << _entity_templets[key];
|
||||
|
||||
QStringList _templets_ids = ilist_conv(_templet_ids);
|
||||
STRLIST_SAVE(_templets_ids);
|
||||
}
|
||||
|
||||
TypesQuery::TypesQuery()
|
||||
:AbstractMessage(NAME(TypesQuery)) {
|
||||
}
|
||||
|
||||
ComponentInfosQuery::ComponentInfosQuery()
|
||||
:AbstractMessage(NAME(ComponentInfosQuery)) {
|
||||
}
|
||||
|
||||
void ComponentInfosQuery::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
UINT64_PEAK(_bind_entity_id);
|
||||
}
|
||||
|
||||
void ComponentInfosQuery::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
UINT64_SAVE(_bind_entity_id);
|
||||
}
|
||||
|
||||
ComponentInfoQueryResult::ComponentInfoQueryResult()
|
||||
:AbstractMessage(NAME(ComponentInfoQueryResult)) {
|
||||
}
|
||||
|
||||
void ComponentInfoQueryResult::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
_entity_json = obj["result_json"].toObject();
|
||||
}
|
||||
|
||||
void ComponentInfoQueryResult::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
obj["result_json"] = _entity_json;
|
||||
}
|
||||
|
||||
TempletOperate::TempletOperate()
|
||||
:AbstractMessage(NAME(TempletOperate)) {
|
||||
}
|
||||
|
||||
void TempletOperate::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
UINT64_PEAK(_operate_code);
|
||||
STRING_PEAK(_template_name);
|
||||
UINT64_PEAK(_template_id_within_0x2ff_0xffff);
|
||||
}
|
||||
|
||||
void TempletOperate::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
UINT64_SAVE(_operate_code);
|
||||
STRING_SAVE(_template_name);
|
||||
UINT64_SAVE(_template_id_within_0x2ff_0xffff);
|
||||
}
|
||||
|
||||
ComponentOperate::ComponentOperate()
|
||||
:AbstractMessage(NAME(ComponentOperate)) {
|
||||
}
|
||||
|
||||
void ComponentOperate::recoveryFrom(const QJsonObject& obj)
|
||||
{
|
||||
AbstractMessage::recoveryFrom(obj);
|
||||
UINT64_PEAK(_entity_id_within_0x2ff_0xffffffffffffffff);
|
||||
STRLIST_PEAK(_component_types);
|
||||
}
|
||||
|
||||
void ComponentOperate::saveTo(QJsonObject& obj) const
|
||||
{
|
||||
AbstractMessage::saveTo(obj);
|
||||
UINT64_SAVE(_entity_id_within_0x2ff_0xffffffffffffffff);
|
||||
STRLIST_SAVE(_component_types);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#define DOUBLE_SAVE(u) obj[NAME(u)] = u
|
||||
#define DOUOBLE_PEAK(u) u = obj[NAME(u)].toDouble()
|
||||
|
||||
#define UINT64_SAVE(u) obj[NAME(u)] = QJsonValue::fromVariant(QVariant::fromValue(u))
|
||||
#define UINT64_PEAK(u) u = obj[NAME(u)].toVariant().toULongLong()
|
||||
|
||||
#define STRING_SAVE(u) obj[NAME(u)] = u
|
||||
#define STRING_PEAK(u) u = obj[NAME(u)].toString()
|
||||
|
||||
|
@ -45,6 +48,8 @@ struct MESSAGEBASIC_EXPORT DeduceRequest : public AbstractMessage {
|
|||
/// </summary>
|
||||
struct MESSAGEBASIC_EXPORT RespondDefault : public AbstractMessage {
|
||||
double _time_consume;
|
||||
bool _success_mark = false;
|
||||
QString _reason_text = "";
|
||||
|
||||
RespondDefault();
|
||||
|
||||
|
@ -109,12 +114,67 @@ struct MESSAGEBASIC_EXPORT Box3DDesc : public AbstractMessage {
|
|||
// 实体构造消息定义 ==========================================
|
||||
|
||||
/// <summary>
|
||||
/// 实体构造
|
||||
/// 查询系统重的组件类型和实体类型
|
||||
/// </summary>
|
||||
struct MESSAGEBASIC_EXPORT EntityAllocte : public AbstractMessage {
|
||||
QString _entity_templet = "";
|
||||
struct MESSAGEBASIC_EXPORT TypesQuery : public AbstractMessage {
|
||||
TypesQuery();
|
||||
};
|
||||
/// <summary>
|
||||
/// 返回系统内所有的组件类型和实体模板类型
|
||||
/// </summary>
|
||||
struct MESSAGEBASIC_EXPORT TypesQueryResult : public AbstractMessage {
|
||||
QStringList _component_types;
|
||||
QHash<QString, uint64_t> _entity_templets;
|
||||
|
||||
EntityAllocte();
|
||||
TypesQueryResult();
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
enum class EntityOperateType {
|
||||
NEW, DELETE, MODIFY
|
||||
};
|
||||
/// <summary>
|
||||
/// 模板操作支持增、删、改
|
||||
/// </summary>
|
||||
struct MESSAGEBASIC_EXPORT TempletOperate : public AbstractMessage {
|
||||
uint64_t _operate_code = (uint64_t)EntityOperateType::NEW;
|
||||
QString _template_name = "";
|
||||
uint64_t _template_id_within_0x2ff_0xffff = 0x2ff;
|
||||
|
||||
TempletOperate();
|
||||
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 实体构造操作
|
||||
/// </summary>
|
||||
struct MESSAGEBASIC_EXPORT EntityOperate : public AbstractMessage {
|
||||
uint64_t _operate_code = (uint64_t)EntityOperateType::NEW;
|
||||
QString _template_name = "";
|
||||
QString _entity_name = "";
|
||||
uint64_t _entity_id_over_0xffff = 0xffff;
|
||||
|
||||
EntityOperate();
|
||||
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
};
|
||||
|
||||
struct MESSAGEBASIC_EXPORT ComponentOperate : public AbstractMessage {
|
||||
uint64_t _entity_id_within_0x2ff_0xffffffffffffffff = 0x2ff;
|
||||
QStringList _component_types;
|
||||
|
||||
ComponentOperate();
|
||||
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
|
@ -135,6 +195,31 @@ struct MESSAGEBASIC_EXPORT EntityTotalList : public AbstractMessage {
|
|||
|
||||
EntityTotalList();
|
||||
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
};
|
||||
|
||||
// componoents_desc ===================================
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定实体的所有组件数据
|
||||
/// </summary>
|
||||
struct MESSAGEBASIC_EXPORT ComponentInfosQuery : public AbstractMessage {
|
||||
uint64_t _bind_entity_id = 0;
|
||||
|
||||
ComponentInfosQuery();
|
||||
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
};
|
||||
|
||||
struct MESSAGEBASIC_EXPORT ComponentInfoQueryResult : public AbstractMessage {
|
||||
QJsonObject _entity_json;
|
||||
|
||||
ComponentInfoQueryResult();
|
||||
|
||||
// 通过 WsMessage 继承
|
||||
void recoveryFrom(const QJsonObject& obj) override;
|
||||
void saveTo(QJsonObject& obj) const override;
|
||||
|
|
|
@ -39,6 +39,8 @@ QString RtEntity::name() const {
|
|||
void RtEntity::append(std::shared_ptr<WsComponent> ins) {
|
||||
if (this->_comps_list.contains(ins->name()))
|
||||
return;
|
||||
|
||||
ins->bindEntity(this->shared_from_this());
|
||||
this->_comps_list[ins->name()] = ins;
|
||||
}
|
||||
|
||||
|
@ -191,6 +193,16 @@ void EntitiesManager::saveTo(QJsonObject& obj) const
|
|||
obj["component_array"] = array;
|
||||
}
|
||||
|
||||
void EntitiesManager::remove(const QString& component_type)
|
||||
{
|
||||
this->_comps_list.remove(component_type);
|
||||
}
|
||||
|
||||
QList<std::shared_ptr<WsComponent>> EntitiesManager::components() const
|
||||
{
|
||||
return this->_comps_list.values();
|
||||
}
|
||||
|
||||
ImmediateCore::ImmediateCore(std::shared_ptr<WsEntity> bind) :_bind_entity(bind) {}
|
||||
|
||||
uint64_t ImmediateCore::entityManagerID() const
|
||||
|
|
|
@ -95,49 +95,6 @@ public:
|
|||
/// </summary>
|
||||
using WsRespondEntry = std::function<void(std::shared_ptr<ImmediateMap> map, std::shared_ptr<const WsMessage>, QList<std::shared_ptr<WsMessage>>&)>;
|
||||
|
||||
/// <summary>
|
||||
/// 功能插件的基类
|
||||
/// </summary>
|
||||
class WsComponent : public Serializable, public std::enable_shared_from_this<WsComponent> {
|
||||
public:
|
||||
virtual ~WsComponent() = default;
|
||||
|
||||
/// <summary>
|
||||
/// 克隆一个具有相同数据的实例
|
||||
/// </summary>
|
||||
/// <returns>实例指针</returns>
|
||||
virtual std::shared_ptr<WsComponent> defaultNew() const = 0;
|
||||
/// <summary>
|
||||
/// 绑定Entity
|
||||
/// </summary>
|
||||
/// <param name="entity_id">EntityID</param>
|
||||
virtual void bindEntity(uint64_t entity_id) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 插件唯一命名
|
||||
/// </summary>
|
||||
/// <returns>插件名</returns>
|
||||
virtual QString name() const = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 允许输入的消息类型
|
||||
/// </summary>
|
||||
/// <returns>消息类型集合</returns>
|
||||
virtual QList<QString> inputTypes() const = 0;
|
||||
/// <summary>
|
||||
/// 通过指定的签名获取处理入口
|
||||
/// </summary>
|
||||
/// <param name="t">处理签名</param>
|
||||
/// <returns>处理接口</returns>
|
||||
virtual QList<WsRespondEntry> getEntryWithSignature(const WsRespondSignatureType& t) const = 0;
|
||||
/// <summary>
|
||||
/// 通过输入消息类型获取处理入口
|
||||
/// </summary>
|
||||
/// <param name="msg_type">输入消息类型</param>
|
||||
/// <returns>处理接口列表</returns>
|
||||
virtual QList<WsRespondEntry> getEntrysWithInType(const QString& msg_type) const = 0;
|
||||
};
|
||||
|
||||
class WsEntity : public Serializable {
|
||||
public:
|
||||
virtual ~WsEntity() = default;
|
||||
|
@ -179,11 +136,73 @@ public:
|
|||
virtual QList<WsRespondEntry> getEntryWithInType(const QString& msg_type) const = 0;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 功能插件的基类
|
||||
/// </summary>
|
||||
class WsComponent : public Serializable, public std::enable_shared_from_this<WsComponent> {
|
||||
public:
|
||||
virtual ~WsComponent() = default;
|
||||
|
||||
/// <summary>
|
||||
/// 克隆一个具有相同数据的实例
|
||||
/// </summary>
|
||||
/// <returns>实例指针</returns>
|
||||
virtual std::shared_ptr<WsComponent> defaultNew() const = 0;
|
||||
/// <summary>
|
||||
/// 绑定Entity
|
||||
/// </summary>
|
||||
/// <param name="entity_id">实体实例</param>
|
||||
virtual void bindEntity(std::weak_ptr<WsEntity> host) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 插件唯一命名
|
||||
/// </summary>
|
||||
/// <returns>插件名</returns>
|
||||
virtual QString name() const = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 允许输入的消息类型
|
||||
/// </summary>
|
||||
/// <returns>消息类型集合</returns>
|
||||
virtual QList<QString> inputTypes() const = 0;
|
||||
/// <summary>
|
||||
/// 通过指定的签名获取处理入口
|
||||
/// </summary>
|
||||
/// <param name="t">处理签名</param>
|
||||
/// <returns>处理接口</returns>
|
||||
virtual QList<WsRespondEntry> getEntryWithSignature(const WsRespondSignatureType& t) const = 0;
|
||||
/// <summary>
|
||||
/// 通过输入消息类型获取处理入口
|
||||
/// </summary>
|
||||
/// <param name="msg_type">输入消息类型</param>
|
||||
/// <returns>处理接口列表</returns>
|
||||
virtual QList<WsRespondEntry> getEntrysWithInType(const QString& msg_type) const = 0;
|
||||
};
|
||||
|
||||
class ComponentSet {
|
||||
public:
|
||||
/// <summary>
|
||||
/// 为本实例添加指定类型的插件
|
||||
/// </summary>
|
||||
/// <param name="ins"></param>
|
||||
virtual void append(std::shared_ptr<WsComponent> ins) = 0;
|
||||
/// <summary>
|
||||
/// 移除指定类型的插件实例
|
||||
/// </summary>
|
||||
/// <param name="component_type"></param>
|
||||
virtual void remove(const QString& component_type) = 0;
|
||||
/// <summary>
|
||||
/// 获取本实例内包含的所有插件实例
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
virtual QList<std::shared_ptr<WsComponent>> components() const = 0;
|
||||
};
|
||||
|
||||
#include <QHash>
|
||||
/// <summary>
|
||||
/// 内存实体实例类型
|
||||
/// </summary>
|
||||
class SIMSBASIC_EXPORT RtEntity : public WsEntity, public std::enable_shared_from_this<RtEntity> {
|
||||
class SIMSBASIC_EXPORT RtEntity : public WsEntity, public ComponentSet, public std::enable_shared_from_this<RtEntity> {
|
||||
private:
|
||||
uint64_t _entity_id = 0;
|
||||
QString _templet_name, _runtime_name;
|
||||
|
@ -229,17 +248,17 @@ public:
|
|||
/// 为本实例添加指定类型的插件
|
||||
/// </summary>
|
||||
/// <param name="ins"></param>
|
||||
virtual void append(std::shared_ptr<WsComponent> ins);
|
||||
virtual void append(std::shared_ptr<WsComponent> ins) override;
|
||||
/// <summary>
|
||||
/// 移除指定类型的插件实例
|
||||
/// </summary>
|
||||
/// <param name="component_type"></param>
|
||||
virtual void remove(const QString& component_type);
|
||||
virtual void remove(const QString& component_type) override;
|
||||
/// <summary>
|
||||
/// 获取本实例内包含的所有插件实例
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
virtual QList<std::shared_ptr<WsComponent>> components() const;
|
||||
virtual QList<std::shared_ptr<WsComponent>> components() const override;
|
||||
|
||||
/// <summary>
|
||||
/// 深度克隆本实例,插件和数据一致
|
||||
|
@ -271,7 +290,9 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class SIMSBASIC_EXPORT EntitiesManager : public WsEntity {
|
||||
class SIMSBASIC_EXPORT EntitiesManager : public WsEntity, public ComponentSet,
|
||||
public std::enable_shared_from_this<EntitiesManager>
|
||||
{
|
||||
public:
|
||||
static const uint64_t const_id = 0x01ff;
|
||||
QHash<QString, std::shared_ptr<WsComponent>> _comps_list;
|
||||
|
@ -280,6 +301,9 @@ public:
|
|||
uint64_t entityID() const override;
|
||||
QString name() const override;
|
||||
void append(std::shared_ptr<WsComponent> ins);
|
||||
void remove(const QString& component_type) override;
|
||||
QList<std::shared_ptr<WsComponent>> components() const override;
|
||||
|
||||
std::shared_ptr<WsEntity> defaultNew() const override;
|
||||
QList<WsRespondEntry> getEntryWithSignature(const WsRespondSignatureType& t) const override;
|
||||
QList<WsRespondEntry> getEntryWithInType(const QString& msg_type) const override;
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
<Keyword>QtVS_v304</Keyword>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')"
|
||||
>$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
|
@ -46,11 +45,8 @@
|
|||
<QtModules>core;gui;widgets</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound"
|
||||
BeforeTargets="CustomBuild;ClCompile"
|
||||
Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
<Message Importance="High"
|
||||
Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||
</Target>
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="Shared" />
|
||||
|
@ -64,9 +60,16 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)StandardGlobe;$(SolutionDir)SimsBasic;$(SolutionDir)MessageBasic;$(SolutionDir)ComponentBasic;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>StandardGlobe.lib;SimsBasic.lib;MessageBasic.lib;ComponentBasic.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
|
@ -96,11 +99,11 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="sims_world.qrc"/>
|
||||
<QtUic Include="sims_world.ui"/>
|
||||
<QtMoc Include="sims_world.h"/>
|
||||
<ClCompile Include="sims_world.cpp"/>
|
||||
<ClCompile Include="main.cpp"/>
|
||||
<QtRcc Include="sims_world.qrc" />
|
||||
<QtUic Include="sims_world.ui" />
|
||||
<QtMoc Include="sims_world.h" />
|
||||
<ClCompile Include="sims_world.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<None Include="SimsWorld.ico" />
|
||||
<ResourceCompile Include="SimsWorld.rc" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -35,14 +35,6 @@
|
|||
<ClCompile Include="sims_world.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ResourceCompile Include="$pro_name$.rc">
|
||||
</ResourceCompile>
|
||||
<None Include="$pro_name$.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="$pro_name$.def">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
<None Include="SimsWorld.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
|
@ -50,4 +42,9 @@
|
|||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,9 +1,12 @@
|
|||
#include "sims_world.h"
|
||||
|
||||
SimsWorld::SimsWorld(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
: QMainWindow(parent),
|
||||
_backend_ins(std::make_shared<DeduceFramework>())
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
_backend_ins->init_backend();
|
||||
}
|
||||
|
||||
SimsWorld::~SimsWorld()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include "ui_sims_world.h"
|
||||
#include <EntityDocks.h>
|
||||
|
||||
class SimsWorld : public QMainWindow
|
||||
{
|
||||
|
@ -13,4 +14,5 @@ public:
|
|||
|
||||
private:
|
||||
Ui::SimsWorldClass ui;
|
||||
std::shared_ptr<DeduceFramework> _backend_ins;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue