diff --git a/ComponentBasic/ComponentBasic.vcxproj b/ComponentBasic/ComponentBasic.vcxproj
index 86ba03e..6644b19 100644
--- a/ComponentBasic/ComponentBasic.vcxproj
+++ b/ComponentBasic/ComponentBasic.vcxproj
@@ -101,10 +101,12 @@
+
+
diff --git a/ComponentBasic/ComponentBasic.vcxproj.filters b/ComponentBasic/ComponentBasic.vcxproj.filters
index ef3a263..981a467 100644
--- a/ComponentBasic/ComponentBasic.vcxproj.filters
+++ b/ComponentBasic/ComponentBasic.vcxproj.filters
@@ -35,6 +35,9 @@
Header Files
+
+ Header Files
+
@@ -43,5 +46,8 @@
Source Files
+
+ Source Files
+
\ No newline at end of file
diff --git a/ComponentBasic/EntitiesManager.cpp b/ComponentBasic/EntitiesManager.cpp
new file mode 100644
index 0000000..735cacb
--- /dev/null
+++ b/ComponentBasic/EntitiesManager.cpp
@@ -0,0 +1 @@
+#include "EntityDocks.h"
diff --git a/ComponentBasic/EntityDocks.h b/ComponentBasic/EntityDocks.h
new file mode 100644
index 0000000..647d4cd
--- /dev/null
+++ b/ComponentBasic/EntityDocks.h
@@ -0,0 +1,2 @@
+#pragma once
+#include
diff --git a/ComponentBasic/VisibleBox.cpp b/ComponentBasic/VisibleBox.cpp
index cc62c80..7cce13f 100644
--- a/ComponentBasic/VisibleBox.cpp
+++ b/ComponentBasic/VisibleBox.cpp
@@ -51,12 +51,12 @@ QString Visible3DPlugin::name() const {
return NAME(Visible3DPlugin);
}
-void Visible3DPlugin::execute(std::shared_ptr in, std::shared_ptr& out)
+void Visible3DPlugin::execute(std::shared_ptr map, std::shared_ptr in, std::shared_ptr& out)
{
auto ins = std::make_shared();
- ins->setPosition(_self_lla);
- ins->setPosture(_self_posture);
- ins->setTarget(_bind_entity, in->sourceEntity());
- ins->setVolume(_self_d3);
+ ins->_lla_pos = _self_lla;
+ ins->_posture_d3 = _self_posture;
+ ins->_d3_data = _self_d3;
+ ins->reset(_bind_entity, in->sourceEntity());
out = ins;
}
diff --git a/ComponentBasic/VisibleBox.h b/ComponentBasic/VisibleBox.h
index 1cdc6c3..afd9101 100644
--- a/ComponentBasic/VisibleBox.h
+++ b/ComponentBasic/VisibleBox.h
@@ -23,7 +23,7 @@ public:
void bindEntity(uint64_t entity_id) override;
QString name() const override;
- void execute(std::shared_ptr in, std::shared_ptr& out) override;
+ void execute(std::shared_ptr map, std::shared_ptr in, std::shared_ptr& out) override;
std::shared_ptr defaultNew() const override;
void recoveryFrom(const QJsonObject& obj) override;
diff --git a/ComponentBasic/componentbasic.h b/ComponentBasic/componentbasic.h
index 14c6139..ae7622c 100644
--- a/ComponentBasic/componentbasic.h
+++ b/ComponentBasic/componentbasic.h
@@ -28,15 +28,15 @@ public:
///
///
///
- virtual void execute(std::shared_ptr in, std::shared_ptr& out) = 0;
+ virtual void execute(std::shared_ptr map, std::shared_ptr in, std::shared_ptr& out) = 0;
///
/// WsRespond构造函数
///
/// 注册函数
explicit WsRespond(QHash& map) {
- WsRespondEntry ins = [=](std::shared_ptr in, std::shared_ptr& out) {
+ WsRespondEntry ins = [=](std::shared_ptr map, std::shared_ptr in, std::shared_ptr& out) {
std::shared_ptr o_ptr;
- this->execute(std::static_pointer_cast(in), o_ptr);
+ this->execute(map, std::static_pointer_cast(in), o_ptr);
out = o_ptr;
};
map[SelfType::signature()] = ins;
diff --git a/MessageBasic/MessageBasic.vcxproj b/MessageBasic/MessageBasic.vcxproj
index c3ba860..4fd6859 100644
--- a/MessageBasic/MessageBasic.vcxproj
+++ b/MessageBasic/MessageBasic.vcxproj
@@ -64,6 +64,11 @@
+
+
+ Default
+
+
true
diff --git a/MessageBasic/messagebasic.cpp b/MessageBasic/messagebasic.cpp
index 4547c7a..da33cc1 100644
--- a/MessageBasic/messagebasic.cpp
+++ b/MessageBasic/messagebasic.cpp
@@ -10,180 +10,56 @@ void from_to_recovery(uint64_t& f, uint64_t& t, const QJsonObject& o) {
t = o["target_entity"].toVariant().toULongLong();
}
-DeduceRequest::DeduceRequest() {}
-
-void DeduceRequest::reset(uint64_t from, uint64_t to) {
- _from_id = from;
- _to_id = to;
+DeduceRequest::DeduceRequest()
+ :AbstractMessage(NAME(DeduceRequest)) {
}
-void DeduceRequest::recoveryFrom(const QJsonObject& obj)
-{
- from_to_recovery(_from_id, _to_id, obj);
-}
-
-void DeduceRequest::saveTo(QJsonObject& obj) const
-{
- from_to_save(_from_id, _to_id, obj);
-}
-
-QString DeduceRequest::topicString() const
-{
- return NAME(DeduceRequest);
-}
-
-uint64_t DeduceRequest::targetEntity() const
-{
- return _to_id;
-}
-
-uint64_t DeduceRequest::sourceEntity() const
-{
- return _from_id;
-}
-
-SyncRequest::SyncRequest() {
-}
-
-void SyncRequest::reset(uint64_t from, uint64_t to, double timepoint)
-{
- _from_id = from;
- _to_id = to;
- this->_time_current = timepoint;
+SyncRequest::SyncRequest()
+ :AbstractMessage(NAME(SyncRequest)),
+ _time_current(0) {
}
void SyncRequest::recoveryFrom(const QJsonObject& obj)
{
- from_to_recovery(_from_id, _to_id, obj);
- this->_time_current = obj["current_time"].toDouble();
+ AbstractMessage::recoveryFrom(obj);
+ DOUOBLE_PEAK(_time_current);
}
void SyncRequest::saveTo(QJsonObject& obj) const
{
- from_to_save(_from_id, _to_id, obj);
- obj["current_time"] = this->_time_current;
+ AbstractMessage::saveTo(obj);
+ DOUBLE_SAVE(_time_current);
}
-QString SyncRequest::topicString() const
-{
- return NAME(SyncRequest);
-}
-
-uint64_t SyncRequest::targetEntity() const
-{
- return _to_id;
-}
-
-uint64_t SyncRequest::sourceEntity() const
-{
- return _from_id;
-}
-
-RespondDefault::RespondDefault() {
-}
-
-void RespondDefault::reset(uint64_t from, uint64_t to, double consume) {
- _from_id = from;
- _to_id = to;
- _time_consume = consume;
-}
-
-double RespondDefault::consume() const {
- return this->_time_consume;
+RespondDefault::RespondDefault()
+ :AbstractMessage(NAME(RespondDefault)),
+ _time_consume(0) {
}
void RespondDefault::recoveryFrom(const QJsonObject& obj)
{
- from_to_recovery(_from_id, _to_id, obj);
- this->_time_consume = obj["time_consume"].toDouble();
+ AbstractMessage::recoveryFrom(obj);
+ DOUOBLE_PEAK(_time_consume);
}
void RespondDefault::saveTo(QJsonObject& obj) const
{
- from_to_save(_from_id, _to_id, obj);
- obj["time_consume"] = this->_time_consume;
-}
-
-QString RespondDefault::topicString() const
-{
- return NAME(DeduceRequest);
-}
-
-uint64_t RespondDefault::targetEntity() const
-{
- return _to_id;
-}
-
-uint64_t RespondDefault::sourceEntity() const
-{
- return _from_id;
+ AbstractMessage::saveTo(obj);
+ DOUBLE_SAVE(_time_consume);
}
Get3DBox::Get3DBox()
-{
-}
-
-void Get3DBox::reset(uint64_t from, uint64_t to)
-{
- _from_id = from;
- _to_id = to;
-}
-
-void Get3DBox::recoveryFrom(const QJsonObject& obj)
-{
- from_to_recovery(_from_id, _to_id, obj);
-}
-
-void Get3DBox::saveTo(QJsonObject& obj) const
-{
- from_to_save(_from_id, _to_id, obj);
-}
-
-QString Get3DBox::topicString() const
-{
- return NAME(Get3DBox);
-}
-
-uint64_t Get3DBox::targetEntity() const
-{
- return _to_id;
-}
-
-uint64_t Get3DBox::sourceEntity() const
-{
- return _from_id;
+ :AbstractMessage(NAME(Get3DBox)) {
}
Box3DDesc::Box3DDesc()
-{
+ :AbstractMessage(NAME(Box3DDesc)) {
}
-void Box3DDesc::setTarget(uint64_t from, uint64_t to) {
- _from_id = from;
- _to_id = to;
-}
-
-void Box3DDesc::setVolume(const D3Data& d) {
- this->_d3_data = d;
-}
-
-D3Data Box3DDesc::volume() const { return this->_d3_data; }
-
-void Box3DDesc::setPosture(const Posture& p) {
- _posture_d3 = p;
-}
-
-Posture Box3DDesc::posture() const { return this->_posture_d3; }
-
-void Box3DDesc::setPosition(const LLAPos& lla) {
- _lla_pos = lla;
-}
-
-LLAPos Box3DDesc::position() const { return this->_lla_pos; }
-
void Box3DDesc::recoveryFrom(const QJsonObject& obj)
{
- from_to_recovery(_from_id, _to_id, obj);
+ AbstractMessage::recoveryFrom(obj);
+
DOUOBLE_PEAK(this->_d3_data._height_m);
DOUOBLE_PEAK(this->_d3_data._length_m);
DOUOBLE_PEAK(this->_d3_data._width_m);
@@ -199,7 +75,7 @@ void Box3DDesc::recoveryFrom(const QJsonObject& obj)
void Box3DDesc::saveTo(QJsonObject& obj) const
{
- from_to_save(_from_id, _to_id, obj);
+ AbstractMessage::saveTo(obj);
DOUBLE_SAVE(this->_d3_data._height_m);
DOUBLE_SAVE(this->_d3_data._length_m);
@@ -214,17 +90,78 @@ void Box3DDesc::saveTo(QJsonObject& obj) const
DOUBLE_SAVE(this->_posture_d3._roll_deg);
}
-QString Box3DDesc::topicString() const
-{
- return NAME(Box3DDesc);
+EntityAllocte::EntityAllocte()
+ :AbstractMessage(NAME(EntityAllocte)) {
}
-uint64_t Box3DDesc::targetEntity() const
+void EntityAllocte::recoveryFrom(const QJsonObject& obj)
+{
+ AbstractMessage::recoveryFrom(obj);
+
+ STRING_PEAK(_entity_templet);
+}
+
+void EntityAllocte::saveTo(QJsonObject& obj) const
+{
+ AbstractMessage::saveTo(obj);
+
+ STRING_SAVE(_entity_templet);
+}
+
+AbstractMessage::AbstractMessage(const QString& topic) :_topic_string(topic) {}
+
+void AbstractMessage::reset(uint64_t from, uint64_t to) {
+ this->_from_id = from;
+ this->_to_id = to;
+}
+
+// 通过 WsMessage 继承
+void AbstractMessage::recoveryFrom(const QJsonObject& obj) {
+ from_to_recovery(_from_id, _to_id, obj);
+}
+
+void AbstractMessage::saveTo(QJsonObject& obj) const
+{
+ from_to_save(_from_id, _to_id, obj);
+}
+
+QString AbstractMessage::topicString() const
+{
+ return _topic_string;
+}
+
+uint64_t AbstractMessage::targetEntity() const
{
return _to_id;
}
-uint64_t Box3DDesc::sourceEntity() const
+uint64_t AbstractMessage::sourceEntity() const
{
return _from_id;
}
+
+EntityTotalGet::EntityTotalGet()
+ :AbstractMessage(NAME(EntityTotalGet)) {
+}
+
+void EntityTotalList::recoveryFrom(const QJsonObject& obj)
+{
+ AbstractMessage::recoveryFrom(obj);
+
+ QStringList strs;
+ STRLIST_PEAK(strs);
+ std::transform(strs.begin(), strs.end(),
+ std::back_inserter(_entities_list),
+ [](QString v) { return v.toULongLong(); });
+}
+
+void EntityTotalList::saveTo(QJsonObject& obj) const
+{
+ AbstractMessage::saveTo(obj);
+
+ QStringList strs;
+ std::transform(_entities_list.begin(), _entities_list.end(),
+ std::back_inserter(strs),
+ [](int v) { return QString(",").arg(v); });
+ STRLIST_SAVE(strs);
+}
diff --git a/MessageBasic/messagebasic.h b/MessageBasic/messagebasic.h
index e9b09ec..8df130c 100644
--- a/MessageBasic/messagebasic.h
+++ b/MessageBasic/messagebasic.h
@@ -8,15 +8,20 @@
#define DOUBLE_SAVE(u) obj[NAME(u)] = u
#define DOUOBLE_PEAK(u) u = obj[NAME(u)].toDouble()
-///
-/// 推演请求
-///
-class MESSAGEBASIC_EXPORT DeduceRequest : public WsMessage {
+#define STRING_SAVE(u) obj[NAME(u)] = u
+#define STRING_PEAK(u) u = obj[NAME(u)].toString()
+
+#define STRLIST_SAVE(u) obj[NAME(u)] = u.join(",")
+#define STRLIST_PEAK(u) u = obj[NAME(u)].toString().split(",")
+
+class MESSAGEBASIC_EXPORT AbstractMessage : public WsMessage {
private:
uint64_t _from_id = 0, _to_id = 0;
+ QString _topic_string;
public:
- DeduceRequest();
+ AbstractMessage(const QString& topic);
+ virtual ~AbstractMessage() = default;
void reset(uint64_t from, uint64_t to);
@@ -28,69 +33,45 @@ public:
uint64_t sourceEntity() const override;
};
+///
+/// 推演请求
+///
+struct MESSAGEBASIC_EXPORT DeduceRequest : public AbstractMessage {
+ DeduceRequest();
+};
+
///
/// 默认的无返回消息的处理过程通用返回消息
///
-class MESSAGEBASIC_EXPORT RespondDefault : public WsMessage {
-private:
- uint64_t _from_id = 0, _to_id = 0;
+struct MESSAGEBASIC_EXPORT RespondDefault : public AbstractMessage {
double _time_consume;
-public:
RespondDefault();
- void reset(uint64_t from, uint64_t to, double consume);
-
- double consume() const;
-
// 通过 WsMessage 继承
void recoveryFrom(const QJsonObject& obj) override;
void saveTo(QJsonObject& obj) const override;
- QString topicString() const override;
- uint64_t targetEntity() const override;
- uint64_t sourceEntity() const override;
};
///
/// 时间同步消息
///
-class MESSAGEBASIC_EXPORT SyncRequest : public WsMessage {
-private:
- uint64_t _from_id = 0, _to_id = 0;
+struct MESSAGEBASIC_EXPORT SyncRequest : public AbstractMessage {
double _time_current;
-public:
SyncRequest();
- void reset(uint64_t from, uint64_t to, double timepoint);
-
// 通过 WsMessage 继承
void recoveryFrom(const QJsonObject& obj) override;
void saveTo(QJsonObject& obj) const override;
- QString topicString() const override;
- uint64_t targetEntity() const override;
- uint64_t sourceEntity() const override;
};
// 体积盒可视化插件定义消息 =======================================================
///
/// 获取体积盒详细数据
///
-class MESSAGEBASIC_EXPORT Get3DBox : public WsMessage {
-private:
- uint64_t _from_id = 0, _to_id = 0;
-
-public:
+struct MESSAGEBASIC_EXPORT Get3DBox : public AbstractMessage {
Get3DBox();
-
- void reset(uint64_t from, uint64_t to);
-
- // 通过 WsMessage 继承
- void recoveryFrom(const QJsonObject& obj) override;
- void saveTo(QJsonObject& obj) const override;
- QString topicString() const override;
- uint64_t targetEntity() const override;
- uint64_t sourceEntity() const override;
};
///
@@ -104,7 +85,7 @@ struct Posture {
///
/// 三维数据结构定义
///
-struct D3Data{
+struct D3Data {
double _length_m = 0;
double _width_m = 0;
double _height_m = 0;
@@ -113,29 +94,41 @@ struct D3Data{
///
/// 体积盒详细数据定义
///
-class MESSAGEBASIC_EXPORT Box3DDesc : public WsMessage {
-private:
- uint64_t _from_id = 0, _to_id = 0;
+struct MESSAGEBASIC_EXPORT Box3DDesc : public AbstractMessage {
D3Data _d3_data;
Posture _posture_d3;
LLAPos _lla_pos;
-public:
Box3DDesc();
- void setTarget(uint64_t from, uint64_t to);
- void setVolume(const D3Data &d);
- D3Data volume() const;
- void setPosture(const Posture &p);
- Posture posture() const;
- void setPosition(const LLAPos &lla);
- LLAPos position() const;
-
-
// 通过 WsMessage 继承
void recoveryFrom(const QJsonObject& obj) override;
void saveTo(QJsonObject& obj) const override;
- QString topicString() const override;
- uint64_t targetEntity() const override;
- uint64_t sourceEntity() const override;
};
+
+// 实体构造消息定义 ==========================================
+
+///
+/// 实体构造
+///
+struct MESSAGEBASIC_EXPORT EntityAllocte : public AbstractMessage {
+ QString _entity_templet = "";
+
+ EntityAllocte();
+
+ // 通过 WsMessage 继承
+ void recoveryFrom(const QJsonObject& obj) override;
+ void saveTo(QJsonObject& obj) const override;
+};
+
+struct MESSAGEBASIC_EXPORT EntityTotalGet : public AbstractMessage {
+ EntityTotalGet();
+};
+
+struct MESSAGEBASIC_EXPORT EntityTotalList : public AbstractMessage {
+ QList _entities_list;
+
+ // 通过 WsMessage 继承
+ void recoveryFrom(const QJsonObject& obj) override;
+ void saveTo(QJsonObject& obj) const override;
+};
\ No newline at end of file
diff --git a/SimsBasic/simsbasic.cpp b/SimsBasic/simsbasic.cpp
index f1c6fbf..0161d28 100644
--- a/SimsBasic/simsbasic.cpp
+++ b/SimsBasic/simsbasic.cpp
@@ -10,48 +10,48 @@ QString UniException::content() const noexcept
return _error_store;
}
-WsEntity::WsEntity() {}
+RtEntity::RtEntity() {}
-void WsEntity::resetTemplet(const QString& name) {
+void RtEntity::resetTemplet(const QString& name) {
this->_templet_name = name;
}
-QString WsEntity::templetName() const {
+QString RtEntity::templetName() const {
return this->_templet_name;
}
-void WsEntity::resetID(uint64_t id) {
+void RtEntity::resetID(uint64_t id) {
this->_entity_id = id;
}
-uint64_t WsEntity::entityID() const {
+uint64_t RtEntity::entityID() const {
return this->_entity_id;
}
-void WsEntity::resetName(const QString& name) {
+void RtEntity::resetName(const QString& name) {
this->_runtime_name = name;
}
-QString WsEntity::name() const {
+QString RtEntity::name() const {
return this->_runtime_name;
}
-void WsEntity::append(std::shared_ptr ins) {
+void RtEntity::append(std::shared_ptr ins) {
if (this->_comps_list.contains(ins->name()))
return;
this->_comps_list[ins->name()] = ins;
}
-void WsEntity::remove(const QString& component_type) {
+void RtEntity::remove(const QString& component_type) {
this->_comps_list.remove(component_type);
}
-QList> WsEntity::components() const {
+QList> RtEntity::components() const {
return _comps_list.values();
}
-std::shared_ptr WsEntity::defaultNew() const {
- auto newx = std::make_shared();
+std::shared_ptr RtEntity::defaultNew() const {
+ auto newx = std::make_shared();
newx->_entity_id = this->_entity_id;
newx->_templet_name = this->_templet_name;
newx->_runtime_name = this->_runtime_name;
@@ -62,7 +62,7 @@ std::shared_ptr WsEntity::defaultNew() const {
}
#include
-QList WsEntity::inputTypes() const
+QList RtEntity::inputTypes() const
{
QList types;
for (auto c : this->_comps_list)
@@ -72,22 +72,22 @@ QList WsEntity::inputTypes() const
#include
#include
-QList WsEntity::getEntryWithSignature(const WsRespondSignatureType& t) const
+QList RtEntity::getEntryWithSignature(const WsRespondSignatureType& t) const
{
QList list;
- for(auto c : this->_comps_list)
+ for (auto c : this->_comps_list)
list.append(c->getEntryWithSignature(t));
return list;
}
-QList WsEntity::getEntryWithInType(const QString& msg_type) const
+QList RtEntity::getEntryWithInType(const QString& msg_type) const
{
QList list;
- for(auto c : this->_comps_list)
+ for (auto c : this->_comps_list)
list.append(c->getEntrysWithInType(msg_type));
return list;
}
-void WsEntity::recoveryFrom(const QJsonObject& obj)
+void RtEntity::recoveryFrom(const QJsonObject& obj)
{
this->_entity_id = obj["entity_id"].toVariant().toULongLong();
this->_runtime_name = obj["entity_name"].toString();
@@ -106,7 +106,7 @@ void WsEntity::recoveryFrom(const QJsonObject& obj)
}
}
-void WsEntity::saveTo(QJsonObject& obj) const
+void RtEntity::saveTo(QJsonObject& obj) const
{
obj["entity_id"] = QJsonValue::fromVariant(QVariant::fromValue(this->_entity_id));
obj["entity_name"] = this->_runtime_name;
@@ -122,3 +122,104 @@ void WsEntity::saveTo(QJsonObject& obj) const
}
obj["component_array"] = array;
}
+
+QString EntitiesManager::templetName() const
+{
+ return "实体管理器";
+}
+
+uint64_t EntitiesManager::entityID() const
+{
+ return const_id;
+}
+
+QString EntitiesManager::name() const
+{
+ return "实体管理器唯一实例";
+}
+
+void EntitiesManager::append(std::shared_ptr ins) {
+ _comps_list[ins->name()] = ins;
+}
+
+std::shared_ptr EntitiesManager::defaultNew() const
+{
+ return nullptr;
+}
+
+QList EntitiesManager::getEntryWithSignature(const WsRespondSignatureType& t) const
+{
+ QList list;
+ for (auto c : this->_comps_list)
+ list.append(c->getEntryWithSignature(t));
+ return list;
+}
+
+QList EntitiesManager::getEntryWithInType(const QString& msg_type) const
+{
+ QList list;
+ for (auto c : this->_comps_list)
+ list.append(c->getEntrysWithInType(msg_type));
+ return list;
+}
+
+void EntitiesManager::recoveryFrom(const QJsonObject& obj)
+{
+ auto array = obj["component_array"].toArray();
+ for (auto idx = 0; idx < array.size(); ++idx) {
+ auto value = array.at(idx).toObject();
+ auto type = value["component_type"].toString();
+
+ auto compins = this->_comps_list[type];
+ if (!compins)
+ throw new UniException(type + "类型插件不存在!");
+
+ compins->recoveryFrom(value);
+ }
+}
+
+void EntitiesManager::saveTo(QJsonObject& obj) const
+{
+ QJsonArray array;
+ for (auto c : this->_comps_list)
+ {
+ QJsonObject comp_obj;
+ comp_obj["component_type"] = c->name();
+ c->saveTo(comp_obj);
+ array.append(comp_obj);
+ }
+ obj["component_array"] = array;
+}
+
+ImmediateCore::ImmediateCore(std::shared_ptr bind) :_bind_entity(bind) {}
+
+uint64_t ImmediateCore::entityManagerID() const
+{
+ return EntitiesManager::const_id;
+}
+
+QList> ImmediateCore::execute(const WsRespondSignatureType& resp_signature, std::shared_ptr in)
+{
+ QList> rets;
+ auto list = this->_bind_entity->getEntryWithSignature(resp_signature);
+ for (auto func : list) {
+ std::shared_ptr out;
+ func(shared_from_this(), in, out);
+
+ if (out) rets << out;
+ }
+ return rets;
+}
+
+QList> ImmediateCore::execute(std::shared_ptr in)
+{
+ QList> rets;
+ auto list = this->_bind_entity->getEntryWithInType(in->topicString());
+ for (auto func : list) {
+ std::shared_ptr out;
+ func(shared_from_this(), in, out);
+
+ if (out) rets << out;
+ }
+ return rets;
+}
diff --git a/SimsBasic/simsbasic.h b/SimsBasic/simsbasic.h
index cdf8226..61ba3c5 100644
--- a/SimsBasic/simsbasic.h
+++ b/SimsBasic/simsbasic.h
@@ -60,15 +60,41 @@ public:
virtual uint64_t sourceEntity() const = 0;
};
-///
-/// 所有消息处理单元通用接口
-///
-using WsRespondEntry = std::function, std::shared_ptr&)>;
///
/// Respond签名类型
///
using WsRespondSignatureType = std::pair;
+///
+/// 实体内立即执行入口
+///
+class ImmediateMap {
+public:
+ virtual ~ImmediateMap() = default;
+ ///
+ /// 获取实体管理器id
+ ///
+ ///
+ virtual uint64_t entityManagerID() const = 0;
+ ///
+ /// 实体内指定类型的调用立即执行
+ ///
+ ///
+ ///
+ virtual QList> execute(const WsRespondSignatureType& resp_signature, std::shared_ptr in) = 0;
+ ///
+ /// 实体内兼容调用立即执行
+ ///
+ ///
+ ///
+ virtual QList> execute(std::shared_ptr in) = 0;
+};
+
+///
+/// 所有消息处理单元通用接口
+///
+using WsRespondEntry = std::function map, std::shared_ptr, std::shared_ptr&)>;
+
///
/// 功能插件的基类
///
@@ -112,19 +138,60 @@ public:
virtual QList getEntrysWithInType(const QString& msg_type) const = 0;
};
+class WsEntity : public Serializable {
+public:
+ virtual ~WsEntity() = default;
+
+ ///
+ /// 获取本实例的模板名
+ ///
+ /// 模板名称
+ virtual QString templetName() const = 0;
+
+ ///
+ /// 获取本实例的运行ID
+ ///
+ ///
+ virtual uint64_t entityID() const = 0;
+ ///
+ /// 获取本实例的运行名称
+ ///
+ /// 运行名称
+ virtual QString name() const = 0;
+
+ ///
+ /// 深度克隆本实例,插件和数据一致
+ ///
+ ///
+ virtual std::shared_ptr defaultNew() const = 0;
+
+ ///
+ /// 通过指定的签名获取处理入口
+ ///
+ /// 签名
+ /// 处理接口
+ virtual QList getEntryWithSignature(const WsRespondSignatureType& t) const = 0;
+ ///
+ /// 通过输入消息类型获取处理入口
+ ///
+ /// 输入消息类型
+ /// 处理接口列表
+ virtual QList getEntryWithInType(const QString& msg_type) const = 0;
+};
+
#include
///
/// 内存实体实例类型
///
-class SIMSBASIC_EXPORT WsEntity : public Serializable, public std::enable_shared_from_this {
+class SIMSBASIC_EXPORT RtEntity : public WsEntity, public std::enable_shared_from_this {
private:
uint64_t _entity_id = 0;
QString _templet_name, _runtime_name;
QHash> _comps_list;
public:
- explicit WsEntity();
- virtual ~WsEntity() = default;
+ explicit RtEntity();
+ virtual ~RtEntity() = default;
///
/// 重置本实例模板名
@@ -180,7 +247,6 @@ public:
///
virtual std::shared_ptr defaultNew() const;
-
///
/// 允许输入的消息类型
///
@@ -202,4 +268,49 @@ public:
// 通过 Serializable 继承
void recoveryFrom(const QJsonObject& obj) override;
void saveTo(QJsonObject& obj) const override;
+};
+
+
+class SIMSBASIC_EXPORT EntitiesManager : public WsEntity {
+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);
+ 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 ImmediateCore : public ImmediateMap, public std::enable_shared_from_this {
+private:
+ std::shared_ptr _bind_entity = nullptr;
+
+public:
+ ImmediateCore(std::shared_ptr bind);
+ ///
+ /// 获取实体管理器id
+ ///
+ ///
+ virtual uint64_t entityManagerID() const override;
+ ///
+ /// 实体内指定类型的调用立即执行
+ ///
+ ///
+ ///
+ virtual QList> execute(const WsRespondSignatureType& resp_signature, std::shared_ptr in) override;
+ ///
+ /// 实体内兼容调用立即执行
+ ///
+ ///
+ ///
+ virtual QList> execute(std::shared_ptr in) override;
+
};
\ No newline at end of file