commit fb27f182dde529d065f02d95566b4471dc4381c6 Author: codeboss <2422523675@qq.com> Date: Sun May 25 12:43:37 2025 +0800 构建初始构型 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4bd821c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +x64/* +.vs/* +*/x64/* \ No newline at end of file diff --git a/ComponentBasic/ComponentBasic.vcxproj b/ComponentBasic/ComponentBasic.vcxproj new file mode 100644 index 0000000..5ede4b3 --- /dev/null +++ b/ComponentBasic/ComponentBasic.vcxproj @@ -0,0 +1,114 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {20CFC220-4F5B-4D39-97FA-74C70768F1A7} + QtVS_v304 + 10.0 + 10.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + DynamicLibrary + v143 + true + Unicode + + + DynamicLibrary + v143 + false + true + Unicode + + + + + + + 5.12.11_msvc2017_64 + core + debug + + + 5.12.11_msvc2017_64 + core + release + + + + + + + + + + + + + + + + + $(SolutionDir)SimsBasic;$(SolutionDir)MessageBasic;$(IncludePath) + $(SolutionDir)$(Platform)\$(Configuration);$(LibraryPath) + + + + + + MessageBasic.lib;%(AdditionalDependencies) + + + + + true + COMPONENTBASIC_LIB;%(PreprocessorDefinitions) + Level3 + true + true + + + Windows + true + + + + + true + COMPONENTBASIC_LIB;%(PreprocessorDefinitions) + Level3 + true + true + true + true + + + Windows + false + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ComponentBasic/ComponentBasic.vcxproj.filters b/ComponentBasic/ComponentBasic.vcxproj.filters new file mode 100644 index 0000000..71afe92 --- /dev/null +++ b/ComponentBasic/ComponentBasic.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + + + Header Files + + + Source Files + + + Header Files + + + \ No newline at end of file diff --git a/ComponentBasic/ComponentBasic.vcxproj.user b/ComponentBasic/ComponentBasic.vcxproj.user new file mode 100644 index 0000000..41a709a --- /dev/null +++ b/ComponentBasic/ComponentBasic.vcxproj.user @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ComponentBasic/componentbasic.cpp b/ComponentBasic/componentbasic.cpp new file mode 100644 index 0000000..e658e37 --- /dev/null +++ b/ComponentBasic/componentbasic.cpp @@ -0,0 +1 @@ +#include "componentbasic.h" diff --git a/ComponentBasic/componentbasic.h b/ComponentBasic/componentbasic.h new file mode 100644 index 0000000..133ac23 --- /dev/null +++ b/ComponentBasic/componentbasic.h @@ -0,0 +1,112 @@ +#pragma once + +#include "componentbasic_global.h" +#include + + +/// +/// ϢԪ +/// +/// +/// +template class WsRespond { +public: + using SelfType = WsRespond; + + virtual ~WsRespond() = default; + /// + /// Respondǩ + /// + /// + static WsRespondSignatureType signature() + { + return std::make_pair(MsgA().topicString(), MsgB().topicString()); + } + + /// + /// ʵʴ + /// + /// + /// + virtual std::shared_ptr execute(std::shared_ptr in) = 0; + /// + /// WsRespond캯 + /// + /// עắ + explicit WsRespond(QHash& map) { + WsRespondEntry ins = [=](std::shared_ptr in) -> std::shared_ptr { + return this->execute(std::static_pointer_cast(in)); + }; + map[SelfType::signature()] = ins; + } +}; + + +template struct _ProcRoute_; +template <> struct COMPONENTBASIC_EXPORT _ProcRoute_<> +{ + QHash _execute_map; + + _ProcRoute_() = default; +}; +template +struct _ProcRoute_ : public _ProcRoute_, public ProcSig +{ + _ProcRoute_() : _ProcRoute_(), ProcSig(_ProcRoute_<>::_execute_map) {} +}; + +template +struct ProcList : public _ProcRoute_, public WsComponent +{ + using SuperType = ProcList; + + ProcList() : _ProcRoute_() {} + + // ͨ WsComponent ̳ + QList inputTypes() const override + { + QList list; + for (auto key : _ProcRoute_<>::_execute_map.keys()) { + list.append(key.first); + } + return list; + } + WsRespondEntry getEntryWithSignature(const WsRespondSignatureType& t) const override + { + for (auto key : _ProcRoute_<>::_execute_map.keys()) { + if (key == t) + return _ProcRoute_<>::_execute_map[key]; + } + } + QList getEntrysWithInType(const QString& msg_type) const override + { + QList list; + for (auto key : _ProcRoute_<>::_execute_map.keys()) { + if (key.first == msg_type) + list.append(_ProcRoute_<>::_execute_map[key]); + } + return list; + } +}; + +#include +class COMPONENTBASIC_EXPORT Visible3DPlugin : public ProcList< + WsRespond +> +{ +public: + + // ͨ ProcList ̳ + std::shared_ptr execute(std::shared_ptr in) override; + + void recoveryFrom(const QJsonObject& obj) override; + + void saveTo(QJsonObject& obj) const override; + + std::shared_ptr defaultNew() const override; + + void bindEntity(uint64_t entity_id) override; + + QString name() const override; + +}; \ No newline at end of file diff --git a/ComponentBasic/componentbasic_global.h b/ComponentBasic/componentbasic_global.h new file mode 100644 index 0000000..3da0605 --- /dev/null +++ b/ComponentBasic/componentbasic_global.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +#ifndef BUILD_STATIC +# if defined(COMPONENTBASIC_LIB) +# define COMPONENTBASIC_EXPORT Q_DECL_EXPORT +# else +# define COMPONENTBASIC_EXPORT Q_DECL_IMPORT +# endif +#else +# define COMPONENTBASIC_EXPORT +#endif diff --git a/MessageBasic/MessageBasic.vcxproj b/MessageBasic/MessageBasic.vcxproj new file mode 100644 index 0000000..0d47bfe --- /dev/null +++ b/MessageBasic/MessageBasic.vcxproj @@ -0,0 +1,108 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {E1104048-F35B-40B7-995C-0320E689BF09} + QtVS_v304 + 10.0 + 10.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + DynamicLibrary + v143 + true + Unicode + + + DynamicLibrary + v143 + false + true + Unicode + + + + + + + 5.12.11_msvc2017_64 + core + debug + + + 5.12.11_msvc2017_64 + core + release + + + + + + + + + + + + + + + + + $(SolutionDir)SimsBasic;$(IncludePath) + + + + + + true + MESSAGEBASIC_LIB;%(PreprocessorDefinitions) + Level3 + true + true + + + Windows + true + + + + + true + MESSAGEBASIC_LIB;%(PreprocessorDefinitions) + Level3 + true + true + true + true + + + Windows + false + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MessageBasic/MessageBasic.vcxproj.filters b/MessageBasic/MessageBasic.vcxproj.filters new file mode 100644 index 0000000..4412b74 --- /dev/null +++ b/MessageBasic/MessageBasic.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + + + Header Files + + + Source Files + + + Header Files + + + \ No newline at end of file diff --git a/MessageBasic/MessageBasic.vcxproj.user b/MessageBasic/MessageBasic.vcxproj.user new file mode 100644 index 0000000..41a709a --- /dev/null +++ b/MessageBasic/MessageBasic.vcxproj.user @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/MessageBasic/messagebasic.cpp b/MessageBasic/messagebasic.cpp new file mode 100644 index 0000000..2ee2434 --- /dev/null +++ b/MessageBasic/messagebasic.cpp @@ -0,0 +1,202 @@ +#include "messagebasic.h" +#include + +void from_to_save(uint64_t f, uint64_t t, QJsonObject& o) { + o["source_entity"] = QJsonValue::fromVariant(QVariant::fromValue(f)); + o["target_entity"] = QJsonValue::fromVariant(QVariant::fromValue(t)); +} +void from_to_recovery(uint64_t& f, uint64_t& t, const QJsonObject& o) { + f = o["source_entity"].toVariant().toULongLong(); + t = o["target_entity"].toVariant().toULongLong(); +} + +DeduceRequest::DeduceRequest() {} + +void DeduceRequest::reset(uint64_t from, uint64_t to) { + _from_id = from; + _to_id = to; +} + +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; +} + +void SyncRequest::recoveryFrom(const QJsonObject& obj) +{ + from_to_recovery(_from_id, _to_id, obj); + this->_time_current = obj["current_time"].toDouble(); +} + +void SyncRequest::saveTo(QJsonObject& obj) const +{ + from_to_save(_from_id, _to_id, obj); + obj["current_time"] = this->_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; +} + +void RespondDefault::recoveryFrom(const QJsonObject& obj) +{ + from_to_recovery(_from_id, _to_id, obj); + this->_time_consume = obj["time_consume"].toDouble(); +} + +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; +} + +Get3DVolume::Get3DVolume() +{ +} + +void Get3DVolume::reset(uint64_t from, uint64_t to) +{ + _from_id = from; + _to_id = to; +} + +void Get3DVolume::recoveryFrom(const QJsonObject& obj) +{ + from_to_recovery(_from_id, _to_id, obj); +} + +void Get3DVolume::saveTo(QJsonObject& obj) const +{ + from_to_save(_from_id, _to_id, obj); +} + +QString Get3DVolume::topicString() const +{ + return NAME(Get3DVolume); +} + +uint64_t Get3DVolume::targetEntity() const +{ + return _to_id; +} + +uint64_t Get3DVolume::sourceEntity() const +{ + return _from_id; +} + +Volume3DDesc::Volume3DDesc() +{ +} + +void Volume3DDesc::reset(uint64_t from, uint64_t to, double l, double w, double h, double azi) +{ + _from_id = from; + _to_id = to; + _length = l; + _width = w; + _height = h; + _azimuth_deg = azi; +} + +void Volume3DDesc::recoveryFrom(const QJsonObject& obj) +{ + from_to_recovery(_from_id, _to_id, obj); + _length = obj["length"].toDouble(); + _width = obj["width"].toDouble(); + _height = obj["height"].toDouble(); + _azimuth_deg = obj["azimuth_deg"].toDouble(); +} + +void Volume3DDesc::saveTo(QJsonObject& obj) const +{ + from_to_save(_from_id, _to_id, obj); + obj["length"] = _length; + obj["width"] = _width; + obj["height"] = _height; + obj["azimuth_deg"] = _azimuth_deg; +} + +QString Volume3DDesc::topicString() const +{ + return NAME(Volume3DDesc); +} + +uint64_t Volume3DDesc::targetEntity() const +{ + return _to_id; +} + +uint64_t Volume3DDesc::sourceEntity() const +{ + return _from_id; +} diff --git a/MessageBasic/messagebasic.h b/MessageBasic/messagebasic.h new file mode 100644 index 0000000..4aaca90 --- /dev/null +++ b/MessageBasic/messagebasic.h @@ -0,0 +1,106 @@ +#pragma once + +#include "messagebasic_global.h" +#include "simsbasic.h" + +#define NAME(v) #v + +/// +/// +/// +class MESSAGEBASIC_EXPORT DeduceRequest : public WsMessage { +private: + uint64_t _from_id, _to_id; + +public: + DeduceRequest(); + + 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; +}; + +/// +/// Ĭϵ޷ϢĴͨ÷Ϣ +/// +class MESSAGEBASIC_EXPORT RespondDefault : public WsMessage { +private: + uint64_t _from_id, _to_id; + 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, _to_id; + 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 Get3DVolume : public WsMessage { +private: + uint64_t _from_id = 0, _to_id = 0; + +public: + Get3DVolume(); + + 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; +}; + +class MESSAGEBASIC_EXPORT Volume3DDesc : public WsMessage { +private: + uint64_t _from_id, _to_id; + double _length, _width, _height; + double _azimuth_deg; + +public: + Volume3DDesc(); + + void reset(uint64_t from, uint64_t to, double l, double w, double h, double azi); + + // ͨ 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; +}; \ No newline at end of file diff --git a/MessageBasic/messagebasic_global.h b/MessageBasic/messagebasic_global.h new file mode 100644 index 0000000..9eae995 --- /dev/null +++ b/MessageBasic/messagebasic_global.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +#ifndef BUILD_STATIC +# if defined(MESSAGEBASIC_LIB) +# define MESSAGEBASIC_EXPORT Q_DECL_EXPORT +# else +# define MESSAGEBASIC_EXPORT Q_DECL_IMPORT +# endif +#else +# define MESSAGEBASIC_EXPORT +#endif diff --git a/SimsBasic/SimsBasic.vcxproj b/SimsBasic/SimsBasic.vcxproj new file mode 100644 index 0000000..0edb828 --- /dev/null +++ b/SimsBasic/SimsBasic.vcxproj @@ -0,0 +1,107 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0} + QtVS_v304 + 10.0 + 10.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + DynamicLibrary + v143 + true + Unicode + + + DynamicLibrary + v143 + false + true + Unicode + + + + + + + 5.12.11_msvc2017_64 + core + debug + + + 5.12.11_msvc2017_64 + core + release + + + + + + + + + + + + + + + + + + + + + + true + SIMSBASIC_LIB;%(PreprocessorDefinitions) + Level3 + true + true + + + Windows + true + + + + + true + SIMSBASIC_LIB;%(PreprocessorDefinitions) + Level3 + true + true + true + true + + + Windows + false + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SimsBasic/SimsBasic.vcxproj.filters b/SimsBasic/SimsBasic.vcxproj.filters new file mode 100644 index 0000000..9d48920 --- /dev/null +++ b/SimsBasic/SimsBasic.vcxproj.filters @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + + + Header Files + + + Source Files + + + Header Files + + + \ No newline at end of file diff --git a/SimsBasic/SimsBasic.vcxproj.user b/SimsBasic/SimsBasic.vcxproj.user new file mode 100644 index 0000000..41a709a --- /dev/null +++ b/SimsBasic/SimsBasic.vcxproj.user @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/SimsBasic/simsbasic.cpp b/SimsBasic/simsbasic.cpp new file mode 100644 index 0000000..f1c6fbf --- /dev/null +++ b/SimsBasic/simsbasic.cpp @@ -0,0 +1,124 @@ +#include "simsbasic.h" + + +UniException::UniException(const QString& msg) + :_error_store(msg) { +} + +QString UniException::content() const noexcept +{ + return _error_store; +} + +WsEntity::WsEntity() {} + +void WsEntity::resetTemplet(const QString& name) { + this->_templet_name = name; +} + +QString WsEntity::templetName() const { + return this->_templet_name; +} + +void WsEntity::resetID(uint64_t id) { + this->_entity_id = id; +} + +uint64_t WsEntity::entityID() const { + return this->_entity_id; +} + +void WsEntity::resetName(const QString& name) { + this->_runtime_name = name; +} + +QString WsEntity::name() const { + return this->_runtime_name; +} + +void WsEntity::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) { + this->_comps_list.remove(component_type); +} + +QList> WsEntity::components() const { + return _comps_list.values(); +} + +std::shared_ptr WsEntity::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; + + for (auto c : this->_comps_list) + newx->append(c->defaultNew()); + return newx; +} + +#include +QList WsEntity::inputTypes() const +{ + QList types; + for (auto c : this->_comps_list) + types.append(c->inputTypes()); + return types.toSet().toList(); +} + +#include +#include +QList WsEntity::getEntryWithSignature(const WsRespondSignatureType& t) const +{ + QList list; + for(auto c : this->_comps_list) + list.append(c->getEntryWithSignature(t)); + return list; +} + +QList WsEntity::getEntryWithInType(const QString& msg_type) const +{ + QList list; + for(auto c : this->_comps_list) + list.append(c->getEntrysWithInType(msg_type)); + return list; +} +void WsEntity::recoveryFrom(const QJsonObject& obj) +{ + this->_entity_id = obj["entity_id"].toVariant().toULongLong(); + this->_runtime_name = obj["entity_name"].toString(); + this->_templet_name = obj["entity_templet"].toString(); + + 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 WsEntity::saveTo(QJsonObject& obj) const +{ + obj["entity_id"] = QJsonValue::fromVariant(QVariant::fromValue(this->_entity_id)); + obj["entity_name"] = this->_runtime_name; + obj["entity_templet"] = this->_templet_name; + + 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; +} diff --git a/SimsBasic/simsbasic.h b/SimsBasic/simsbasic.h new file mode 100644 index 0000000..fc3c7ef --- /dev/null +++ b/SimsBasic/simsbasic.h @@ -0,0 +1,205 @@ +#pragma once + +#include "simsbasic_global.h" +#include +#include +#include + +/// +/// л +/// +class Serializable { +public: + virtual ~Serializable() = default; + /// + /// ͨлȫָ + /// + /// Json + virtual void recoveryFrom(const QJsonObject& obj) = 0; + /// + /// ͨл + /// + /// ĿJson + virtual void saveTo(QJsonObject& obj) const = 0; +}; + +/// +/// 쳣 +/// +class SIMSBASIC_EXPORT UniException { +private: + QString _error_store; + +public: + explicit UniException(const QString& msg); + virtual ~UniException() = default; + + virtual QString content() const noexcept; +}; + +/// +/// ͨϢ +/// +class WsMessage : public Serializable { +public: + virtual ~WsMessage() = default; + /// + /// ȡϢַ + /// + /// Ϣ + virtual QString topicString() const = 0; + /// + /// ĿʵID + /// + /// ID + virtual uint64_t targetEntity() const = 0; + /// + /// ԴʵID + /// + /// ID + virtual uint64_t sourceEntity() const = 0; +}; + +/// +/// ϢԪͨýӿ +/// +using WsRespondEntry = std::function(std::shared_ptr)>; +/// +/// Respondǩ +/// +using WsRespondSignatureType = std::pair; + +/// +/// ܲĻ +/// +class WsComponent : public Serializable, public std::enable_shared_from_this { +public: + virtual ~WsComponent() = default; + + /// + /// ¡һͬݵʵ + /// + /// ʵָ + virtual std::shared_ptr defaultNew() const = 0; + /// + /// Entity + /// + /// EntityID + virtual void bindEntity(uint64_t entity_id) = 0; + + /// + /// Ψһ + /// + /// + virtual QString name() const = 0; + + /// + /// Ϣ + /// + /// Ϣͼ + virtual QList inputTypes() const = 0; + /// + /// ָͨǩȡ + /// + /// ǩ + /// ӿ + virtual WsRespondEntry getEntryWithSignature(const WsRespondSignatureType& t) const = 0; + /// + /// ͨϢͻȡ + /// + /// Ϣ + /// ӿб + virtual QList getEntrysWithInType(const QString& msg_type) const = 0; +}; + +#include +/// +/// ڴʵʵ +/// +class SIMSBASIC_EXPORT WsEntity : public Serializable, 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; + + /// + /// ñʵģ + /// + /// ģ + virtual void resetTemplet(const QString& name); + /// + /// ȡʵģ + /// + /// ģ + virtual QString templetName() const; + + /// + /// ñʵID + /// + /// + virtual void resetID(uint64_t id); + /// + /// ȡʵID + /// + /// + virtual uint64_t entityID() const; + /// + /// ñʵ + /// + /// + virtual void resetName(const QString& name); + /// + /// ȡʵ + /// + /// + virtual QString name() const; + + /// + /// Ϊʵָ͵IJ + /// + /// + virtual void append(std::shared_ptr ins); + /// + /// Ƴָ͵IJʵ + /// + /// + virtual void remove(const QString& component_type); + /// + /// ȡʵڰвʵ + /// + /// + virtual QList> components() const; + + /// + /// ȿ¡ʵһ + /// + /// + virtual std::shared_ptr defaultNew() const; + + + /// + /// Ϣ + /// + /// Ϣͼ + virtual QList inputTypes() const; + /// + /// ָͨǩȡ + /// + /// ǩ + /// ӿ + virtual QList getEntryWithSignature(const WsRespondSignatureType& t) const; + /// + /// ͨϢͻȡ + /// + /// Ϣ + /// ӿб + virtual QList getEntryWithInType(const QString& msg_type) const; + + // ͨ Serializable ̳ + void recoveryFrom(const QJsonObject& obj) override; + void saveTo(QJsonObject& obj) const override; +}; \ No newline at end of file diff --git a/SimsBasic/simsbasic_global.h b/SimsBasic/simsbasic_global.h new file mode 100644 index 0000000..2376d3a --- /dev/null +++ b/SimsBasic/simsbasic_global.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +#ifndef BUILD_STATIC +# if defined(SIMSBASIC_LIB) +# define SIMSBASIC_EXPORT Q_DECL_EXPORT +# else +# define SIMSBASIC_EXPORT Q_DECL_IMPORT +# endif +#else +# define SIMSBASIC_EXPORT +#endif diff --git a/SimsWorld.sln b/SimsWorld.sln new file mode 100644 index 0000000..98a9502 --- /dev/null +++ b/SimsWorld.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35825.156 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsWorld", "SimsWorld\SimsWorld.vcxproj", "{46E3FBA5-6775-4638-AE2E-935675D3B9CE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimsBasic", "SimsBasic\SimsBasic.vcxproj", "{DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComponentBasic", "ComponentBasic\ComponentBasic.vcxproj", "{20CFC220-4F5B-4D39-97FA-74C70768F1A7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MessageBasic", "MessageBasic\MessageBasic.vcxproj", "{E1104048-F35B-40B7-995C-0320E689BF09}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46E3FBA5-6775-4638-AE2E-935675D3B9CE}.Debug|x64.ActiveCfg = Debug|x64 + {46E3FBA5-6775-4638-AE2E-935675D3B9CE}.Debug|x64.Build.0 = Debug|x64 + {46E3FBA5-6775-4638-AE2E-935675D3B9CE}.Release|x64.ActiveCfg = Release|x64 + {46E3FBA5-6775-4638-AE2E-935675D3B9CE}.Release|x64.Build.0 = Release|x64 + {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}.Debug|x64.ActiveCfg = Debug|x64 + {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}.Debug|x64.Build.0 = Debug|x64 + {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}.Release|x64.ActiveCfg = Release|x64 + {DF15B899-B9AE-4EBE-8FCC-436C9DB6CEF0}.Release|x64.Build.0 = Release|x64 + {20CFC220-4F5B-4D39-97FA-74C70768F1A7}.Debug|x64.ActiveCfg = Debug|x64 + {20CFC220-4F5B-4D39-97FA-74C70768F1A7}.Debug|x64.Build.0 = Debug|x64 + {20CFC220-4F5B-4D39-97FA-74C70768F1A7}.Release|x64.ActiveCfg = Release|x64 + {20CFC220-4F5B-4D39-97FA-74C70768F1A7}.Release|x64.Build.0 = Release|x64 + {E1104048-F35B-40B7-995C-0320E689BF09}.Debug|x64.ActiveCfg = Debug|x64 + {E1104048-F35B-40B7-995C-0320E689BF09}.Debug|x64.Build.0 = Debug|x64 + {E1104048-F35B-40B7-995C-0320E689BF09}.Release|x64.ActiveCfg = Release|x64 + {E1104048-F35B-40B7-995C-0320E689BF09}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6FB4589F-9657-44A5-9137-24A66C2A5057} + EndGlobalSection +EndGlobal diff --git a/SimsWorld/SimsWorld.ico b/SimsWorld/SimsWorld.ico new file mode 100644 index 0000000..1c4fb80 Binary files /dev/null and b/SimsWorld/SimsWorld.ico differ diff --git a/SimsWorld/SimsWorld.rc b/SimsWorld/SimsWorld.rc new file mode 100644 index 0000000..5559e55 --- /dev/null +++ b/SimsWorld/SimsWorld.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "SimsWorld.ico" diff --git a/SimsWorld/SimsWorld.vcxproj b/SimsWorld/SimsWorld.vcxproj new file mode 100644 index 0000000..d1a14fa --- /dev/null +++ b/SimsWorld/SimsWorld.vcxproj @@ -0,0 +1,113 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {46E3FBA5-6775-4638-AE2E-935675D3B9CE} + QtVS_v304 + 10.0 + 10.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + Application + v143 + true + Unicode + + + Application + v143 + false + true + Unicode + + + + + + + 5.12.11_msvc2017_64 + core;gui;widgets + debug + + + 5.12.11_msvc2017_64 + core;gui;widgets + release + + + + + + + + + + + + + + + + + + + + + + true + Level3 + true + true + + + Windows + true + + + + + true + Level3 + true + true + true + true + + + Windows + false + true + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SimsWorld/SimsWorld.vcxproj.filters b/SimsWorld/SimsWorld.vcxproj.filters new file mode 100644 index 0000000..e0efcd9 --- /dev/null +++ b/SimsWorld/SimsWorld.vcxproj.filters @@ -0,0 +1,53 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + + + Resource Files + + + Form Files + + + Header Files + + + Source Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + diff --git a/SimsWorld/SimsWorld.vcxproj.user b/SimsWorld/SimsWorld.vcxproj.user new file mode 100644 index 0000000..41a709a --- /dev/null +++ b/SimsWorld/SimsWorld.vcxproj.user @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/SimsWorld/main.cpp b/SimsWorld/main.cpp new file mode 100644 index 0000000..3bb7154 --- /dev/null +++ b/SimsWorld/main.cpp @@ -0,0 +1,10 @@ +#include "sims_world.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + SimsWorld w; + w.show(); + return a.exec(); +} diff --git a/SimsWorld/sims_world.cpp b/SimsWorld/sims_world.cpp new file mode 100644 index 0000000..0875831 --- /dev/null +++ b/SimsWorld/sims_world.cpp @@ -0,0 +1,10 @@ +#include "sims_world.h" + +SimsWorld::SimsWorld(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); +} + +SimsWorld::~SimsWorld() +{} diff --git a/SimsWorld/sims_world.h b/SimsWorld/sims_world.h new file mode 100644 index 0000000..921040f --- /dev/null +++ b/SimsWorld/sims_world.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include "ui_sims_world.h" + +class SimsWorld : public QMainWindow +{ + Q_OBJECT + +public: + SimsWorld(QWidget *parent = nullptr); + ~SimsWorld(); + +private: + Ui::SimsWorldClass ui; +}; diff --git a/SimsWorld/sims_world.qrc b/SimsWorld/sims_world.qrc new file mode 100644 index 0000000..45fffd3 --- /dev/null +++ b/SimsWorld/sims_world.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/SimsWorld/sims_world.ui b/SimsWorld/sims_world.ui new file mode 100644 index 0000000..47a1865 --- /dev/null +++ b/SimsWorld/sims_world.ui @@ -0,0 +1,28 @@ + + SimsWorldClass + + + SimsWorldClass + + + + 0 + 0 + 600 + 400 + + + + SimsWorld + + + + + + + + + + + +