From 89665f3ce72ead28c126aac444fd98466dcbdccc Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Thu, 6 Jul 2023 09:29:11 +0200 Subject: [PATCH] ADD: added new version of Orders and a first use in the entity base class --- CMakeLists.txt | 1 + include/Orders/MoveOrder.hpp | 28 ++-- include/Orders/Order.hpp | 11 +- include/Orders/protos/MoveOrder.pb.cc | 145 +++++++++++------- include/Orders/protos/MoveOrder.pb.h | 93 +++++++++--- include/Orders/protos/MoveOrder.proto | 5 +- include/Orders/protos/Order.pb.cc | 110 +------------- include/Orders/protos/Order.pb.h | 210 -------------------------- include/Orders/protos/Order.proto | 2 - src/Entities/Entity.cpp | 21 ++- src/Orders/MoveOrder.cpp | 100 ++++++------ src/Orders/Order.cpp | 11 +- 12 files changed, 263 insertions(+), 474 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98068d7..029bf76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ SimCore eigen loguru nlohmann_json +OrderLibrary ) # add_dependencies(SimCore protoc) diff --git a/include/Orders/MoveOrder.hpp b/include/Orders/MoveOrder.hpp index cfe9005..3e1294e 100644 --- a/include/Orders/MoveOrder.hpp +++ b/include/Orders/MoveOrder.hpp @@ -1,7 +1,9 @@ #pragma once +#include "SimCore/data.hpp" #include #include +#include #include namespace Orders @@ -9,33 +11,33 @@ namespace Orders class MoveOrder: public Order { public: - MoveOrder(const SimCore::Identifier id,const SimCore::Identifier orderingEntity,const SimCore::Identifier orderedEntity,WHISPER::SourceType srcType); + MoveOrder(const SimCore::Identifier OwnID, WHISPER::SourceType srcType); - MoveOrder(const SimCore::Identifier id,const SimCore::Identifier orderingEntity,const SimCore::Identifier orderedEntity,WHISPER::SourceType srcType,SimCore::Position pos,double speed = 0, int startTime = 0); + MoveOrder(const SimCore::Identifier OwnID,WHISPER::SourceType srcType,SimCore::Position pos,double speed = 0,double course = 0, int startTime = 0); ~MoveOrder(); - void addData(SimCore::Position pos,double speed = 0, int startTime = 0); void setPosition(SimCore::Position pos); - void setSpeed(double speed); - void setStartTime(uint64_t startTime); + SimCore::Position getPosition(); - double getSpeed(); - uint64_t getStartTime(); - - virtual WHISPER::Message buildMessage(SimCore::Identifier parentID) override; + + virtual WHISPER::Message buildMessage() override; - static std::shared_ptr unpack(WHISPER::Message msg); + static std::unique_ptr unpack(WHISPER::Message msg); + static std::unique_ptr unpack(std::string msg); + SimCore::Data Course; + SimCore::Data Speed; + SimCore::Data StartTime; + private: - SimCore::Position pos_; - double speed_ = 0; - uint64_t startTime_ = 0; + SimCore::Position pos_; + }; diff --git a/include/Orders/Order.hpp b/include/Orders/Order.hpp index dc2fd23..241b49d 100644 --- a/include/Orders/Order.hpp +++ b/include/Orders/Order.hpp @@ -16,26 +16,25 @@ namespace Orders class Order { public: - Order(const SimCore::Identifier id,const SimCore::Identifier orderingEntity,const SimCore::Identifier orderedEntity,const WHISPER::SourceType srcType, const Orders::OrderType OrderType_); + Order(const SimCore::Identifier OwnID,const WHISPER::SourceType srcType, const Orders::OrderType OrderType_); const SimCore::Identifier getOrderID(); - const SimCore::Identifier getOrderingEntity(); - const SimCore::Identifier getOrderedEntity(); + const SimCore::Identifier getOwnID(); + const WHISPER::SourceType srcType; const Orders::OrderType getOrderType(); protected: - virtual WHISPER::Message buildMessage(SimCore::Identifier parentID) = 0; + virtual WHISPER::Message buildMessage() = 0; private: const SimCore::Identifier orderID_; - const SimCore::Identifier orderingEntity_; - const SimCore::Identifier orderedEntity_; + const SimCore::Identifier OwnID_; const Orders::OrderType OrderType_; diff --git a/include/Orders/protos/MoveOrder.pb.cc b/include/Orders/protos/MoveOrder.pb.cc index 9ea995e..794096f 100644 --- a/include/Orders/protos/MoveOrder.pb.cc +++ b/include/Orders/protos/MoveOrder.pb.cc @@ -29,7 +29,8 @@ PROTOBUF_CONSTEXPR MoveOrder::MoveOrder( , /*decltype(_impl_._cached_size_)*/{} , /*decltype(_impl_.geocentricposition_)*/nullptr , /*decltype(_impl_.startingtime_)*/nullptr - , /*decltype(_impl_.speed_)*/0} {} + , /*decltype(_impl_.speed_)*/0 + , /*decltype(_impl_.course_)*/0} {} struct MoveOrderDefaultTypeInternal { PROTOBUF_CONSTEXPR MoveOrderDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -55,13 +56,15 @@ const uint32_t TableStruct_MoveOrder_2eproto::offsets[] PROTOBUF_SECTION_VARIABL ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::messages::entity::order::MoveOrder, _impl_.geocentricposition_), PROTOBUF_FIELD_OFFSET(::messages::entity::order::MoveOrder, _impl_.speed_), + PROTOBUF_FIELD_OFFSET(::messages::entity::order::MoveOrder, _impl_.course_), PROTOBUF_FIELD_OFFSET(::messages::entity::order::MoveOrder, _impl_.startingtime_), - ~0u, - 1, 0, + 2, + 3, + 1, }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 9, -1, sizeof(::messages::entity::order::MoveOrder)}, + { 0, 10, -1, sizeof(::messages::entity::order::MoveOrder)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -71,12 +74,13 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_MoveOrder_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\017MoveOrder.proto\022\025messages.entity.order" "\032\030GeocentricPosition.proto\032\037google/proto" - "buf/timestamp.proto\"\267\001\n\tMoveOrder\022D\n\022Geo" + "buf/timestamp.proto\"\363\001\n\tMoveOrder\022I\n\022Geo" "centricPosition\030\001 \001(\0132(.messages.track.E" - "ntityGeocentricPosition\022\022\n\005speed\030\002 \001(\001H\000" - "\210\001\001\0225\n\014startingTime\030\003 \001(\0132\032.google.proto" - "buf.TimestampH\001\210\001\001B\010\n\006_speedB\017\n\r_startin" - "gTimeb\006proto3" + "ntityGeocentricPositionH\000\210\001\001\022\022\n\005speed\030\002 " + "\001(\001H\001\210\001\001\022\023\n\006course\030\003 \001(\001H\002\210\001\001\0225\n\014startin" + "gTime\030\004 \001(\0132\032.google.protobuf.TimestampH" + "\003\210\001\001B\025\n\023_GeocentricPositionB\010\n\006_speedB\t\n" + "\007_courseB\017\n\r_startingTimeb\006proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_MoveOrder_2eproto_deps[2] = { &::descriptor_table_GeocentricPosition_2eproto, @@ -84,7 +88,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_MoveOrder_2eproto_d }; static ::_pbi::once_flag descriptor_table_MoveOrder_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_MoveOrder_2eproto = { - false, false, 293, descriptor_table_protodef_MoveOrder_2eproto, + false, false, 353, descriptor_table_protodef_MoveOrder_2eproto, "MoveOrder.proto", &descriptor_table_MoveOrder_2eproto_once, descriptor_table_MoveOrder_2eproto_deps, 2, 1, schemas, file_default_instances, TableStruct_MoveOrder_2eproto::offsets, @@ -107,12 +111,18 @@ class MoveOrder::_Internal { public: using HasBits = decltype(std::declval()._impl_._has_bits_); static const ::messages::track::EntityGeocentricPosition& geocentricposition(const MoveOrder* msg); + static void set_has_geocentricposition(HasBits* has_bits) { + (*has_bits)[0] |= 1u; + } static void set_has_speed(HasBits* has_bits) { - (*has_bits)[0] |= 2u; + (*has_bits)[0] |= 4u; + } + static void set_has_course(HasBits* has_bits) { + (*has_bits)[0] |= 8u; } static const ::PROTOBUF_NAMESPACE_ID::Timestamp& startingtime(const MoveOrder* msg); static void set_has_startingtime(HasBits* has_bits) { - (*has_bits)[0] |= 1u; + (*has_bits)[0] |= 2u; } }; @@ -125,14 +135,12 @@ MoveOrder::_Internal::startingtime(const MoveOrder* msg) { return *msg->_impl_.startingtime_; } void MoveOrder::clear_geocentricposition() { - if (GetArenaForAllocation() == nullptr && _impl_.geocentricposition_ != nullptr) { - delete _impl_.geocentricposition_; - } - _impl_.geocentricposition_ = nullptr; + if (_impl_.geocentricposition_ != nullptr) _impl_.geocentricposition_->Clear(); + _impl_._has_bits_[0] &= ~0x00000001u; } void MoveOrder::clear_startingtime() { if (_impl_.startingtime_ != nullptr) _impl_.startingtime_->Clear(); - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; } MoveOrder::MoveOrder(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) @@ -148,7 +156,8 @@ MoveOrder::MoveOrder(const MoveOrder& from) , /*decltype(_impl_._cached_size_)*/{} , decltype(_impl_.geocentricposition_){nullptr} , decltype(_impl_.startingtime_){nullptr} - , decltype(_impl_.speed_){}}; + , decltype(_impl_.speed_){} + , decltype(_impl_.course_){}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); if (from._internal_has_geocentricposition()) { @@ -157,7 +166,9 @@ MoveOrder::MoveOrder(const MoveOrder& from) if (from._internal_has_startingtime()) { _this->_impl_.startingtime_ = new ::PROTOBUF_NAMESPACE_ID::Timestamp(*from._impl_.startingtime_); } - _this->_impl_.speed_ = from._impl_.speed_; + ::memcpy(&_impl_.speed_, &from._impl_.speed_, + static_cast(reinterpret_cast(&_impl_.course_) - + reinterpret_cast(&_impl_.speed_)) + sizeof(_impl_.course_)); // @@protoc_insertion_point(copy_constructor:messages.entity.order.MoveOrder) } @@ -171,6 +182,7 @@ inline void MoveOrder::SharedCtor( , decltype(_impl_.geocentricposition_){nullptr} , decltype(_impl_.startingtime_){nullptr} , decltype(_impl_.speed_){0} + , decltype(_impl_.course_){0} }; } @@ -199,16 +211,22 @@ void MoveOrder::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - if (GetArenaForAllocation() == nullptr && _impl_.geocentricposition_ != nullptr) { - delete _impl_.geocentricposition_; - } - _impl_.geocentricposition_ = nullptr; cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000001u) { - GOOGLE_DCHECK(_impl_.startingtime_ != nullptr); - _impl_.startingtime_->Clear(); + if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x00000001u) { + GOOGLE_DCHECK(_impl_.geocentricposition_ != nullptr); + _impl_.geocentricposition_->Clear(); + } + if (cached_has_bits & 0x00000002u) { + GOOGLE_DCHECK(_impl_.startingtime_ != nullptr); + _impl_.startingtime_->Clear(); + } + } + if (cached_has_bits & 0x0000000cu) { + ::memset(&_impl_.speed_, 0, static_cast( + reinterpret_cast(&_impl_.course_) - + reinterpret_cast(&_impl_.speed_)) + sizeof(_impl_.course_)); } - _impl_.speed_ = 0; _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -220,7 +238,7 @@ const char* MoveOrder::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // .messages.track.EntityGeocentricPosition GeocentricPosition = 1; + // optional .messages.track.EntityGeocentricPosition GeocentricPosition = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { ptr = ctx->ParseMessage(_internal_mutable_geocentricposition(), ptr); @@ -237,9 +255,18 @@ const char* MoveOrder::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx } else goto handle_unusual; continue; - // optional .google.protobuf.Timestamp startingTime = 3; + // optional double course = 3; case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 25)) { + _Internal::set_has_course(&has_bits); + _impl_.course_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); + ptr += sizeof(double); + } else + goto handle_unusual; + continue; + // optional .google.protobuf.Timestamp startingTime = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { ptr = ctx->ParseMessage(_internal_mutable_startingtime(), ptr); CHK_(ptr); } else @@ -275,8 +302,8 @@ uint8_t* MoveOrder::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - // .messages.track.EntityGeocentricPosition GeocentricPosition = 1; - if (this->_internal_has_geocentricposition()) { + // optional .messages.track.EntityGeocentricPosition GeocentricPosition = 1; + if (_internal_has_geocentricposition()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: InternalWriteMessage(1, _Internal::geocentricposition(this), _Internal::geocentricposition(this).GetCachedSize(), target, stream); @@ -288,10 +315,16 @@ uint8_t* MoveOrder::_InternalSerialize( target = ::_pbi::WireFormatLite::WriteDoubleToArray(2, this->_internal_speed(), target); } - // optional .google.protobuf.Timestamp startingTime = 3; + // optional double course = 3; + if (_internal_has_course()) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteDoubleToArray(3, this->_internal_course(), target); + } + + // optional .google.protobuf.Timestamp startingTime = 4; if (_internal_has_startingtime()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::startingtime(this), + InternalWriteMessage(4, _Internal::startingtime(this), _Internal::startingtime(this).GetCachedSize(), target, stream); } @@ -311,24 +344,29 @@ size_t MoveOrder::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // .messages.track.EntityGeocentricPosition GeocentricPosition = 1; - if (this->_internal_has_geocentricposition()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.geocentricposition_); - } - cached_has_bits = _impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { - // optional .google.protobuf.Timestamp startingTime = 3; + if (cached_has_bits & 0x0000000fu) { + // optional .messages.track.EntityGeocentricPosition GeocentricPosition = 1; if (cached_has_bits & 0x00000001u) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.geocentricposition_); + } + + // optional .google.protobuf.Timestamp startingTime = 4; + if (cached_has_bits & 0x00000002u) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( *_impl_.startingtime_); } // optional double speed = 2; - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { + total_size += 1 + 8; + } + + // optional double course = 3; + if (cached_has_bits & 0x00000008u) { total_size += 1 + 8; } @@ -351,19 +389,22 @@ void MoveOrder::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROT uint32_t cached_has_bits = 0; (void) cached_has_bits; - if (from._internal_has_geocentricposition()) { - _this->_internal_mutable_geocentricposition()->::messages::track::EntityGeocentricPosition::MergeFrom( - from._internal_geocentricposition()); - } cached_has_bits = from._impl_._has_bits_[0]; - if (cached_has_bits & 0x00000003u) { + if (cached_has_bits & 0x0000000fu) { if (cached_has_bits & 0x00000001u) { + _this->_internal_mutable_geocentricposition()->::messages::track::EntityGeocentricPosition::MergeFrom( + from._internal_geocentricposition()); + } + if (cached_has_bits & 0x00000002u) { _this->_internal_mutable_startingtime()->::PROTOBUF_NAMESPACE_ID::Timestamp::MergeFrom( from._internal_startingtime()); } - if (cached_has_bits & 0x00000002u) { + if (cached_has_bits & 0x00000004u) { _this->_impl_.speed_ = from._impl_.speed_; } + if (cached_has_bits & 0x00000008u) { + _this->_impl_.course_ = from._impl_.course_; + } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); @@ -385,8 +426,8 @@ void MoveOrder::InternalSwap(MoveOrder* other) { _internal_metadata_.InternalSwap(&other->_internal_metadata_); swap(_impl_._has_bits_[0], other->_impl_._has_bits_[0]); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(MoveOrder, _impl_.speed_) - + sizeof(MoveOrder::_impl_.speed_) + PROTOBUF_FIELD_OFFSET(MoveOrder, _impl_.course_) + + sizeof(MoveOrder::_impl_.course_) - PROTOBUF_FIELD_OFFSET(MoveOrder, _impl_.geocentricposition_)>( reinterpret_cast(&_impl_.geocentricposition_), reinterpret_cast(&other->_impl_.geocentricposition_)); diff --git a/include/Orders/protos/MoveOrder.pb.h b/include/Orders/protos/MoveOrder.pb.h index a969610..8cdf0da 100644 --- a/include/Orders/protos/MoveOrder.pb.h +++ b/include/Orders/protos/MoveOrder.pb.h @@ -186,10 +186,11 @@ class MoveOrder final : enum : int { kGeocentricPositionFieldNumber = 1, - kStartingTimeFieldNumber = 3, + kStartingTimeFieldNumber = 4, kSpeedFieldNumber = 2, + kCourseFieldNumber = 3, }; - // .messages.track.EntityGeocentricPosition GeocentricPosition = 1; + // optional .messages.track.EntityGeocentricPosition GeocentricPosition = 1; bool has_geocentricposition() const; private: bool _internal_has_geocentricposition() const; @@ -207,7 +208,7 @@ class MoveOrder final : ::messages::track::EntityGeocentricPosition* geocentricposition); ::messages::track::EntityGeocentricPosition* unsafe_arena_release_geocentricposition(); - // optional .google.protobuf.Timestamp startingTime = 3; + // optional .google.protobuf.Timestamp startingTime = 4; bool has_startingtime() const; private: bool _internal_has_startingtime() const; @@ -238,6 +239,19 @@ class MoveOrder final : void _internal_set_speed(double value); public: + // optional double course = 3; + bool has_course() const; + private: + bool _internal_has_course() const; + public: + void clear_course(); + double course() const; + void set_course(double value); + private: + double _internal_course() const; + void _internal_set_course(double value); + public: + // @@protoc_insertion_point(class_scope:messages.entity.order.MoveOrder) private: class _Internal; @@ -251,6 +265,7 @@ class MoveOrder final : ::messages::track::EntityGeocentricPosition* geocentricposition_; ::PROTOBUF_NAMESPACE_ID::Timestamp* startingtime_; double speed_; + double course_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_MoveOrder_2eproto; @@ -266,9 +281,11 @@ class MoveOrder final : #endif // __GNUC__ // MoveOrder -// .messages.track.EntityGeocentricPosition GeocentricPosition = 1; +// optional .messages.track.EntityGeocentricPosition GeocentricPosition = 1; inline bool MoveOrder::_internal_has_geocentricposition() const { - return this != internal_default_instance() && _impl_.geocentricposition_ != nullptr; + bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + PROTOBUF_ASSUME(!value || _impl_.geocentricposition_ != nullptr); + return value; } inline bool MoveOrder::has_geocentricposition() const { return _internal_has_geocentricposition(); @@ -289,14 +306,14 @@ inline void MoveOrder::unsafe_arena_set_allocated_geocentricposition( } _impl_.geocentricposition_ = geocentricposition; if (geocentricposition) { - + _impl_._has_bits_[0] |= 0x00000001u; } else { - + _impl_._has_bits_[0] &= ~0x00000001u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:messages.entity.order.MoveOrder.GeocentricPosition) } inline ::messages::track::EntityGeocentricPosition* MoveOrder::release_geocentricposition() { - + _impl_._has_bits_[0] &= ~0x00000001u; ::messages::track::EntityGeocentricPosition* temp = _impl_.geocentricposition_; _impl_.geocentricposition_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -312,13 +329,13 @@ inline ::messages::track::EntityGeocentricPosition* MoveOrder::release_geocentri } inline ::messages::track::EntityGeocentricPosition* MoveOrder::unsafe_arena_release_geocentricposition() { // @@protoc_insertion_point(field_release:messages.entity.order.MoveOrder.GeocentricPosition) - + _impl_._has_bits_[0] &= ~0x00000001u; ::messages::track::EntityGeocentricPosition* temp = _impl_.geocentricposition_; _impl_.geocentricposition_ = nullptr; return temp; } inline ::messages::track::EntityGeocentricPosition* MoveOrder::_internal_mutable_geocentricposition() { - + _impl_._has_bits_[0] |= 0x00000001u; if (_impl_.geocentricposition_ == nullptr) { auto* p = CreateMaybeMessage<::messages::track::EntityGeocentricPosition>(GetArenaForAllocation()); _impl_.geocentricposition_ = p; @@ -343,9 +360,9 @@ inline void MoveOrder::set_allocated_geocentricposition(::messages::track::Entit geocentricposition = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, geocentricposition, submessage_arena); } - + _impl_._has_bits_[0] |= 0x00000001u; } else { - + _impl_._has_bits_[0] &= ~0x00000001u; } _impl_.geocentricposition_ = geocentricposition; // @@protoc_insertion_point(field_set_allocated:messages.entity.order.MoveOrder.GeocentricPosition) @@ -353,7 +370,7 @@ inline void MoveOrder::set_allocated_geocentricposition(::messages::track::Entit // optional double speed = 2; inline bool MoveOrder::_internal_has_speed() const { - bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000004u) != 0; return value; } inline bool MoveOrder::has_speed() const { @@ -361,7 +378,7 @@ inline bool MoveOrder::has_speed() const { } inline void MoveOrder::clear_speed() { _impl_.speed_ = 0; - _impl_._has_bits_[0] &= ~0x00000002u; + _impl_._has_bits_[0] &= ~0x00000004u; } inline double MoveOrder::_internal_speed() const { return _impl_.speed_; @@ -371,7 +388,7 @@ inline double MoveOrder::speed() const { return _internal_speed(); } inline void MoveOrder::_internal_set_speed(double value) { - _impl_._has_bits_[0] |= 0x00000002u; + _impl_._has_bits_[0] |= 0x00000004u; _impl_.speed_ = value; } inline void MoveOrder::set_speed(double value) { @@ -379,9 +396,37 @@ inline void MoveOrder::set_speed(double value) { // @@protoc_insertion_point(field_set:messages.entity.order.MoveOrder.speed) } -// optional .google.protobuf.Timestamp startingTime = 3; +// optional double course = 3; +inline bool MoveOrder::_internal_has_course() const { + bool value = (_impl_._has_bits_[0] & 0x00000008u) != 0; + return value; +} +inline bool MoveOrder::has_course() const { + return _internal_has_course(); +} +inline void MoveOrder::clear_course() { + _impl_.course_ = 0; + _impl_._has_bits_[0] &= ~0x00000008u; +} +inline double MoveOrder::_internal_course() const { + return _impl_.course_; +} +inline double MoveOrder::course() const { + // @@protoc_insertion_point(field_get:messages.entity.order.MoveOrder.course) + return _internal_course(); +} +inline void MoveOrder::_internal_set_course(double value) { + _impl_._has_bits_[0] |= 0x00000008u; + _impl_.course_ = value; +} +inline void MoveOrder::set_course(double value) { + _internal_set_course(value); + // @@protoc_insertion_point(field_set:messages.entity.order.MoveOrder.course) +} + +// optional .google.protobuf.Timestamp startingTime = 4; inline bool MoveOrder::_internal_has_startingtime() const { - bool value = (_impl_._has_bits_[0] & 0x00000001u) != 0; + bool value = (_impl_._has_bits_[0] & 0x00000002u) != 0; PROTOBUF_ASSUME(!value || _impl_.startingtime_ != nullptr); return value; } @@ -404,14 +449,14 @@ inline void MoveOrder::unsafe_arena_set_allocated_startingtime( } _impl_.startingtime_ = startingtime; if (startingtime) { - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; } // @@protoc_insertion_point(field_unsafe_arena_set_allocated:messages.entity.order.MoveOrder.startingTime) } inline ::PROTOBUF_NAMESPACE_ID::Timestamp* MoveOrder::release_startingtime() { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; ::PROTOBUF_NAMESPACE_ID::Timestamp* temp = _impl_.startingtime_; _impl_.startingtime_ = nullptr; #ifdef PROTOBUF_FORCE_COPY_IN_RELEASE @@ -427,13 +472,13 @@ inline ::PROTOBUF_NAMESPACE_ID::Timestamp* MoveOrder::release_startingtime() { } inline ::PROTOBUF_NAMESPACE_ID::Timestamp* MoveOrder::unsafe_arena_release_startingtime() { // @@protoc_insertion_point(field_release:messages.entity.order.MoveOrder.startingTime) - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; ::PROTOBUF_NAMESPACE_ID::Timestamp* temp = _impl_.startingtime_; _impl_.startingtime_ = nullptr; return temp; } inline ::PROTOBUF_NAMESPACE_ID::Timestamp* MoveOrder::_internal_mutable_startingtime() { - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000002u; if (_impl_.startingtime_ == nullptr) { auto* p = CreateMaybeMessage<::PROTOBUF_NAMESPACE_ID::Timestamp>(GetArenaForAllocation()); _impl_.startingtime_ = p; @@ -458,9 +503,9 @@ inline void MoveOrder::set_allocated_startingtime(::PROTOBUF_NAMESPACE_ID::Times startingtime = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( message_arena, startingtime, submessage_arena); } - _impl_._has_bits_[0] |= 0x00000001u; + _impl_._has_bits_[0] |= 0x00000002u; } else { - _impl_._has_bits_[0] &= ~0x00000001u; + _impl_._has_bits_[0] &= ~0x00000002u; } _impl_.startingtime_ = startingtime; // @@protoc_insertion_point(field_set_allocated:messages.entity.order.MoveOrder.startingTime) diff --git a/include/Orders/protos/MoveOrder.proto b/include/Orders/protos/MoveOrder.proto index 70708f1..64f10aa 100644 --- a/include/Orders/protos/MoveOrder.proto +++ b/include/Orders/protos/MoveOrder.proto @@ -9,8 +9,9 @@ import "google/protobuf/timestamp.proto"; message MoveOrder { -messages.track.EntityGeocentricPosition GeocentricPosition = 1; +optional messages.track.EntityGeocentricPosition GeocentricPosition = 1; optional double speed = 2; -optional google.protobuf.Timestamp startingTime = 3; +optional double course = 3; +optional google.protobuf.Timestamp startingTime = 4; } \ No newline at end of file diff --git a/include/Orders/protos/Order.pb.cc b/include/Orders/protos/Order.pb.cc index bc56fa7..ba9f7b3 100644 --- a/include/Orders/protos/Order.pb.cc +++ b/include/Orders/protos/Order.pb.cc @@ -26,8 +26,6 @@ namespace order { PROTOBUF_CONSTEXPR Order::Order( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.orderid_)*/nullptr - , /*decltype(_impl_.orderingentity_)*/nullptr - , /*decltype(_impl_.orderedentity_)*/nullptr , /*decltype(_impl_.orderpayload_)*/nullptr , /*decltype(_impl_.ordertype_)*/0u , /*decltype(_impl_._cached_size_)*/{}} {} @@ -55,8 +53,6 @@ const uint32_t TableStruct_Order_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(pr ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ PROTOBUF_FIELD_OFFSET(::messages::entity::order::Order, _impl_.orderid_), - PROTOBUF_FIELD_OFFSET(::messages::entity::order::Order, _impl_.orderingentity_), - PROTOBUF_FIELD_OFFSET(::messages::entity::order::Order, _impl_.orderedentity_), PROTOBUF_FIELD_OFFSET(::messages::entity::order::Order, _impl_.ordertype_), PROTOBUF_FIELD_OFFSET(::messages::entity::order::Order, _impl_.orderpayload_), }; @@ -71,12 +67,10 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_Order_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\013Order.proto\022\025messages.entity.order\032\020Id" "entifier.proto\032\031google/protobuf/any.prot" - "o\"\332\001\n\005Order\022+\n\007OrderID\030\001 \001(\0132\032.messages." - "track.Identifier\0222\n\016orderingEntity\030\002 \001(\013" - "2\032.messages.track.Identifier\0221\n\rorderedE" - "ntity\030\003 \001(\0132\032.messages.track.Identifier\022" - "\021\n\tOrderType\030\004 \001(\r\022*\n\014OrderPayload\030\005 \001(\013" - "2\024.google.protobuf.Anyb\006proto3" + "o\"s\n\005Order\022+\n\007OrderID\030\001 \001(\0132\032.messages.t" + "rack.Identifier\022\021\n\tOrderType\030\004 \001(\r\022*\n\014Or" + "derPayload\030\005 \001(\0132\024.google.protobuf.Anyb\006" + "proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_Order_2eproto_deps[2] = { &::descriptor_table_Identifier_2eproto, @@ -84,7 +78,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_Order_2eproto_deps[ }; static ::_pbi::once_flag descriptor_table_Order_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_Order_2eproto = { - false, false, 310, descriptor_table_protodef_Order_2eproto, + false, false, 206, descriptor_table_protodef_Order_2eproto, "Order.proto", &descriptor_table_Order_2eproto_once, descriptor_table_Order_2eproto_deps, 2, 1, schemas, file_default_instances, TableStruct_Order_2eproto::offsets, @@ -106,8 +100,6 @@ namespace order { class Order::_Internal { public: static const ::messages::track::Identifier& orderid(const Order* msg); - static const ::messages::track::Identifier& orderingentity(const Order* msg); - static const ::messages::track::Identifier& orderedentity(const Order* msg); static const ::PROTOBUF_NAMESPACE_ID::Any& orderpayload(const Order* msg); }; @@ -115,14 +107,6 @@ const ::messages::track::Identifier& Order::_Internal::orderid(const Order* msg) { return *msg->_impl_.orderid_; } -const ::messages::track::Identifier& -Order::_Internal::orderingentity(const Order* msg) { - return *msg->_impl_.orderingentity_; -} -const ::messages::track::Identifier& -Order::_Internal::orderedentity(const Order* msg) { - return *msg->_impl_.orderedentity_; -} const ::PROTOBUF_NAMESPACE_ID::Any& Order::_Internal::orderpayload(const Order* msg) { return *msg->_impl_.orderpayload_; @@ -133,18 +117,6 @@ void Order::clear_orderid() { } _impl_.orderid_ = nullptr; } -void Order::clear_orderingentity() { - if (GetArenaForAllocation() == nullptr && _impl_.orderingentity_ != nullptr) { - delete _impl_.orderingentity_; - } - _impl_.orderingentity_ = nullptr; -} -void Order::clear_orderedentity() { - if (GetArenaForAllocation() == nullptr && _impl_.orderedentity_ != nullptr) { - delete _impl_.orderedentity_; - } - _impl_.orderedentity_ = nullptr; -} void Order::clear_orderpayload() { if (GetArenaForAllocation() == nullptr && _impl_.orderpayload_ != nullptr) { delete _impl_.orderpayload_; @@ -162,8 +134,6 @@ Order::Order(const Order& from) Order* const _this = this; (void)_this; new (&_impl_) Impl_{ decltype(_impl_.orderid_){nullptr} - , decltype(_impl_.orderingentity_){nullptr} - , decltype(_impl_.orderedentity_){nullptr} , decltype(_impl_.orderpayload_){nullptr} , decltype(_impl_.ordertype_){} , /*decltype(_impl_._cached_size_)*/{}}; @@ -172,12 +142,6 @@ Order::Order(const Order& from) if (from._internal_has_orderid()) { _this->_impl_.orderid_ = new ::messages::track::Identifier(*from._impl_.orderid_); } - if (from._internal_has_orderingentity()) { - _this->_impl_.orderingentity_ = new ::messages::track::Identifier(*from._impl_.orderingentity_); - } - if (from._internal_has_orderedentity()) { - _this->_impl_.orderedentity_ = new ::messages::track::Identifier(*from._impl_.orderedentity_); - } if (from._internal_has_orderpayload()) { _this->_impl_.orderpayload_ = new ::PROTOBUF_NAMESPACE_ID::Any(*from._impl_.orderpayload_); } @@ -191,8 +155,6 @@ inline void Order::SharedCtor( (void)is_message_owned; new (&_impl_) Impl_{ decltype(_impl_.orderid_){nullptr} - , decltype(_impl_.orderingentity_){nullptr} - , decltype(_impl_.orderedentity_){nullptr} , decltype(_impl_.orderpayload_){nullptr} , decltype(_impl_.ordertype_){0u} , /*decltype(_impl_._cached_size_)*/{} @@ -211,8 +173,6 @@ Order::~Order() { inline void Order::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); if (this != internal_default_instance()) delete _impl_.orderid_; - if (this != internal_default_instance()) delete _impl_.orderingentity_; - if (this != internal_default_instance()) delete _impl_.orderedentity_; if (this != internal_default_instance()) delete _impl_.orderpayload_; } @@ -230,14 +190,6 @@ void Order::Clear() { delete _impl_.orderid_; } _impl_.orderid_ = nullptr; - if (GetArenaForAllocation() == nullptr && _impl_.orderingentity_ != nullptr) { - delete _impl_.orderingentity_; - } - _impl_.orderingentity_ = nullptr; - if (GetArenaForAllocation() == nullptr && _impl_.orderedentity_ != nullptr) { - delete _impl_.orderedentity_; - } - _impl_.orderedentity_ = nullptr; if (GetArenaForAllocation() == nullptr && _impl_.orderpayload_ != nullptr) { delete _impl_.orderpayload_; } @@ -260,22 +212,6 @@ const char* Order::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { } else goto handle_unusual; continue; - // .messages.track.Identifier orderingEntity = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { - ptr = ctx->ParseMessage(_internal_mutable_orderingentity(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // .messages.track.Identifier orderedEntity = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { - ptr = ctx->ParseMessage(_internal_mutable_orderedentity(), ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; // uint32 OrderType = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { @@ -328,20 +264,6 @@ uint8_t* Order::_InternalSerialize( _Internal::orderid(this).GetCachedSize(), target, stream); } - // .messages.track.Identifier orderingEntity = 2; - if (this->_internal_has_orderingentity()) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(2, _Internal::orderingentity(this), - _Internal::orderingentity(this).GetCachedSize(), target, stream); - } - - // .messages.track.Identifier orderedEntity = 3; - if (this->_internal_has_orderedentity()) { - target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::orderedentity(this), - _Internal::orderedentity(this).GetCachedSize(), target, stream); - } - // uint32 OrderType = 4; if (this->_internal_ordertype() != 0) { target = stream->EnsureSpace(target); @@ -378,20 +300,6 @@ size_t Order::ByteSizeLong() const { *_impl_.orderid_); } - // .messages.track.Identifier orderingEntity = 2; - if (this->_internal_has_orderingentity()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.orderingentity_); - } - - // .messages.track.Identifier orderedEntity = 3; - if (this->_internal_has_orderedentity()) { - total_size += 1 + - ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( - *_impl_.orderedentity_); - } - // .google.protobuf.Any OrderPayload = 5; if (this->_internal_has_orderpayload()) { total_size += 1 + @@ -426,14 +334,6 @@ void Order::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF _this->_internal_mutable_orderid()->::messages::track::Identifier::MergeFrom( from._internal_orderid()); } - if (from._internal_has_orderingentity()) { - _this->_internal_mutable_orderingentity()->::messages::track::Identifier::MergeFrom( - from._internal_orderingentity()); - } - if (from._internal_has_orderedentity()) { - _this->_internal_mutable_orderedentity()->::messages::track::Identifier::MergeFrom( - from._internal_orderedentity()); - } if (from._internal_has_orderpayload()) { _this->_internal_mutable_orderpayload()->::PROTOBUF_NAMESPACE_ID::Any::MergeFrom( from._internal_orderpayload()); diff --git a/include/Orders/protos/Order.pb.h b/include/Orders/protos/Order.pb.h index d5fbcf4..3b11e90 100644 --- a/include/Orders/protos/Order.pb.h +++ b/include/Orders/protos/Order.pb.h @@ -186,8 +186,6 @@ class Order final : enum : int { kOrderIDFieldNumber = 1, - kOrderingEntityFieldNumber = 2, - kOrderedEntityFieldNumber = 3, kOrderPayloadFieldNumber = 5, kOrderTypeFieldNumber = 4, }; @@ -209,42 +207,6 @@ class Order final : ::messages::track::Identifier* orderid); ::messages::track::Identifier* unsafe_arena_release_orderid(); - // .messages.track.Identifier orderingEntity = 2; - bool has_orderingentity() const; - private: - bool _internal_has_orderingentity() const; - public: - void clear_orderingentity(); - const ::messages::track::Identifier& orderingentity() const; - PROTOBUF_NODISCARD ::messages::track::Identifier* release_orderingentity(); - ::messages::track::Identifier* mutable_orderingentity(); - void set_allocated_orderingentity(::messages::track::Identifier* orderingentity); - private: - const ::messages::track::Identifier& _internal_orderingentity() const; - ::messages::track::Identifier* _internal_mutable_orderingentity(); - public: - void unsafe_arena_set_allocated_orderingentity( - ::messages::track::Identifier* orderingentity); - ::messages::track::Identifier* unsafe_arena_release_orderingentity(); - - // .messages.track.Identifier orderedEntity = 3; - bool has_orderedentity() const; - private: - bool _internal_has_orderedentity() const; - public: - void clear_orderedentity(); - const ::messages::track::Identifier& orderedentity() const; - PROTOBUF_NODISCARD ::messages::track::Identifier* release_orderedentity(); - ::messages::track::Identifier* mutable_orderedentity(); - void set_allocated_orderedentity(::messages::track::Identifier* orderedentity); - private: - const ::messages::track::Identifier& _internal_orderedentity() const; - ::messages::track::Identifier* _internal_mutable_orderedentity(); - public: - void unsafe_arena_set_allocated_orderedentity( - ::messages::track::Identifier* orderedentity); - ::messages::track::Identifier* unsafe_arena_release_orderedentity(); - // .google.protobuf.Any OrderPayload = 5; bool has_orderpayload() const; private: @@ -281,8 +243,6 @@ class Order final : typedef void DestructorSkippable_; struct Impl_ { ::messages::track::Identifier* orderid_; - ::messages::track::Identifier* orderingentity_; - ::messages::track::Identifier* orderedentity_; ::PROTOBUF_NAMESPACE_ID::Any* orderpayload_; uint32_t ordertype_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; @@ -386,176 +346,6 @@ inline void Order::set_allocated_orderid(::messages::track::Identifier* orderid) // @@protoc_insertion_point(field_set_allocated:messages.entity.order.Order.OrderID) } -// .messages.track.Identifier orderingEntity = 2; -inline bool Order::_internal_has_orderingentity() const { - return this != internal_default_instance() && _impl_.orderingentity_ != nullptr; -} -inline bool Order::has_orderingentity() const { - return _internal_has_orderingentity(); -} -inline const ::messages::track::Identifier& Order::_internal_orderingentity() const { - const ::messages::track::Identifier* p = _impl_.orderingentity_; - return p != nullptr ? *p : reinterpret_cast( - ::messages::track::_Identifier_default_instance_); -} -inline const ::messages::track::Identifier& Order::orderingentity() const { - // @@protoc_insertion_point(field_get:messages.entity.order.Order.orderingEntity) - return _internal_orderingentity(); -} -inline void Order::unsafe_arena_set_allocated_orderingentity( - ::messages::track::Identifier* orderingentity) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.orderingentity_); - } - _impl_.orderingentity_ = orderingentity; - if (orderingentity) { - - } else { - - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:messages.entity.order.Order.orderingEntity) -} -inline ::messages::track::Identifier* Order::release_orderingentity() { - - ::messages::track::Identifier* temp = _impl_.orderingentity_; - _impl_.orderingentity_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::messages::track::Identifier* Order::unsafe_arena_release_orderingentity() { - // @@protoc_insertion_point(field_release:messages.entity.order.Order.orderingEntity) - - ::messages::track::Identifier* temp = _impl_.orderingentity_; - _impl_.orderingentity_ = nullptr; - return temp; -} -inline ::messages::track::Identifier* Order::_internal_mutable_orderingentity() { - - if (_impl_.orderingentity_ == nullptr) { - auto* p = CreateMaybeMessage<::messages::track::Identifier>(GetArenaForAllocation()); - _impl_.orderingentity_ = p; - } - return _impl_.orderingentity_; -} -inline ::messages::track::Identifier* Order::mutable_orderingentity() { - ::messages::track::Identifier* _msg = _internal_mutable_orderingentity(); - // @@protoc_insertion_point(field_mutable:messages.entity.order.Order.orderingEntity) - return _msg; -} -inline void Order::set_allocated_orderingentity(::messages::track::Identifier* orderingentity) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.orderingentity_); - } - if (orderingentity) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(orderingentity)); - if (message_arena != submessage_arena) { - orderingentity = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, orderingentity, submessage_arena); - } - - } else { - - } - _impl_.orderingentity_ = orderingentity; - // @@protoc_insertion_point(field_set_allocated:messages.entity.order.Order.orderingEntity) -} - -// .messages.track.Identifier orderedEntity = 3; -inline bool Order::_internal_has_orderedentity() const { - return this != internal_default_instance() && _impl_.orderedentity_ != nullptr; -} -inline bool Order::has_orderedentity() const { - return _internal_has_orderedentity(); -} -inline const ::messages::track::Identifier& Order::_internal_orderedentity() const { - const ::messages::track::Identifier* p = _impl_.orderedentity_; - return p != nullptr ? *p : reinterpret_cast( - ::messages::track::_Identifier_default_instance_); -} -inline const ::messages::track::Identifier& Order::orderedentity() const { - // @@protoc_insertion_point(field_get:messages.entity.order.Order.orderedEntity) - return _internal_orderedentity(); -} -inline void Order::unsafe_arena_set_allocated_orderedentity( - ::messages::track::Identifier* orderedentity) { - if (GetArenaForAllocation() == nullptr) { - delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.orderedentity_); - } - _impl_.orderedentity_ = orderedentity; - if (orderedentity) { - - } else { - - } - // @@protoc_insertion_point(field_unsafe_arena_set_allocated:messages.entity.order.Order.orderedEntity) -} -inline ::messages::track::Identifier* Order::release_orderedentity() { - - ::messages::track::Identifier* temp = _impl_.orderedentity_; - _impl_.orderedentity_ = nullptr; -#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE - auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - if (GetArenaForAllocation() == nullptr) { delete old; } -#else // PROTOBUF_FORCE_COPY_IN_RELEASE - if (GetArenaForAllocation() != nullptr) { - temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); - } -#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE - return temp; -} -inline ::messages::track::Identifier* Order::unsafe_arena_release_orderedentity() { - // @@protoc_insertion_point(field_release:messages.entity.order.Order.orderedEntity) - - ::messages::track::Identifier* temp = _impl_.orderedentity_; - _impl_.orderedentity_ = nullptr; - return temp; -} -inline ::messages::track::Identifier* Order::_internal_mutable_orderedentity() { - - if (_impl_.orderedentity_ == nullptr) { - auto* p = CreateMaybeMessage<::messages::track::Identifier>(GetArenaForAllocation()); - _impl_.orderedentity_ = p; - } - return _impl_.orderedentity_; -} -inline ::messages::track::Identifier* Order::mutable_orderedentity() { - ::messages::track::Identifier* _msg = _internal_mutable_orderedentity(); - // @@protoc_insertion_point(field_mutable:messages.entity.order.Order.orderedEntity) - return _msg; -} -inline void Order::set_allocated_orderedentity(::messages::track::Identifier* orderedentity) { - ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); - if (message_arena == nullptr) { - delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.orderedentity_); - } - if (orderedentity) { - ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = - ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( - reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(orderedentity)); - if (message_arena != submessage_arena) { - orderedentity = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( - message_arena, orderedentity, submessage_arena); - } - - } else { - - } - _impl_.orderedentity_ = orderedentity; - // @@protoc_insertion_point(field_set_allocated:messages.entity.order.Order.orderedEntity) -} - // uint32 OrderType = 4; inline void Order::clear_ordertype() { _impl_.ordertype_ = 0u; diff --git a/include/Orders/protos/Order.proto b/include/Orders/protos/Order.proto index 721623f..53a2e9a 100644 --- a/include/Orders/protos/Order.proto +++ b/include/Orders/protos/Order.proto @@ -7,8 +7,6 @@ import "google/protobuf/any.proto"; message Order { messages.track.Identifier OrderID = 1; -messages.track.Identifier orderingEntity = 2; -messages.track.Identifier orderedEntity = 3; uint32 OrderType = 4; diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index eb2f665..dbddce8 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1,5 +1,6 @@ #include "DirectCommunicationServer.hpp" #include "Entities/Movement.hpp" +#include "Orders/MoveOrder.hpp" #include "SimCore/Messages/SimTrack.hpp" #include "WHISPER/InternalUDPListener.hpp" #include "WHISPER/InternalUDPSender.hpp" @@ -53,30 +54,28 @@ namespace Entities void Entity::setPosition(SimCore::Position pos) { OwnShipTrack->setPosition(pos); - SimCore::SimTrack newSimTrack(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY,EntityKind_); - newSimTrack.setPosition(pos); + Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY); + moveorder.setPosition(pos); + } void Entity::setSpeed(double val) { OwnShipTrack->Speed.setValue(val); - SimCore::SimTrack newSimTrack(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY,EntityKind_); - newSimTrack.Speed.setValue(val); - MovemtServer_->sendMessage(newSimTrack.buildMessage().serialize()); + Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY); } void Entity::setCourse(double val) { OwnShipTrack->Course.setValue(val); - SimCore::SimTrack newSimTrack(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY,EntityKind_); - newSimTrack.Course.setValue(val); - LOG_S(INFO)<< "NEW Course: "<< val; - MovemtServer_->sendMessage(newSimTrack.buildMessage().serialize()); + Orders::MoveOrder moveorder(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY); + moveorder.Course.setValue(val); + MovemtServer_->sendMessage(moveorder.buildMessage().serialize()); + } void Entity::setPitch( double val) { OwnShipTrack->Pitch.setValue(val); - SimCore::SimTrack newSimTrack(OwnShipTrack->getIdentifier(),WHISPER::SourceType::ENTITY,EntityKind_); - newSimTrack.Pitch.setValue(val); + } diff --git a/src/Orders/MoveOrder.cpp b/src/Orders/MoveOrder.cpp index a9643e4..6e47f12 100644 --- a/src/Orders/MoveOrder.cpp +++ b/src/Orders/MoveOrder.cpp @@ -1,22 +1,32 @@ #include "SimCore/Position.hpp" +#include "SimCore/data.hpp" #include #include #include #include #include +#include namespace Orders { - MoveOrder::MoveOrder(const SimCore::Identifier id,const SimCore::Identifier orderingEntity,const SimCore::Identifier orderedEntity,WHISPER::SourceType srcType): - Order(id, orderingEntity, orderedEntity,srcType,Orders::MOVE_ORDER) + MoveOrder::MoveOrder(const SimCore::Identifier OwnID, WHISPER::SourceType srcType): + Order(OwnID,srcType,Orders::MOVE_ORDER) { + Speed = SimCore::Data(); + Course = SimCore::Data(); + StartTime = SimCore::Data(); + pos_ = SimCore::Position(); } - MoveOrder::MoveOrder(const SimCore::Identifier id,const SimCore::Identifier orderingEntity,const SimCore::Identifier orderedEntity,WHISPER::SourceType srcType,SimCore::Position pos,double speed, int startTime ): - Order(id, orderingEntity, orderedEntity,srcType,Orders::MOVE_ORDER),speed_(speed),startTime_(startTime) + MoveOrder::MoveOrder(const SimCore::Identifier OwnID,WHISPER::SourceType srcType,SimCore::Position pos,double speed,double course , int startTime ): + Order(OwnID, srcType,Orders::MOVE_ORDER) { + Speed = SimCore::Data(); + Course = SimCore::Data(); + StartTime = SimCore::Data(); + pos_ = SimCore::Position(); } @@ -25,51 +35,41 @@ namespace Orders } - void MoveOrder::addData(SimCore::Position pos,double speed, int startTime ) - { - pos_ = pos; - speed_ = speed; - startTime_ = startTime; - - } - + void MoveOrder::setPosition(SimCore::Position pos) { pos_ = pos; } - void MoveOrder::setSpeed(double speed) - { - speed_ = speed; - } - - void MoveOrder::setStartTime(uint64_t startTime) - { - startTime_ = startTime; - } + SimCore::Position MoveOrder::getPosition(){return pos_;} - double MoveOrder::getSpeed(){return speed_;} - uint64_t MoveOrder::getStartTime(){return startTime_;} + - WHISPER::Message MoveOrder::buildMessage(SimCore::Identifier parentID) + WHISPER::Message MoveOrder::buildMessage() { - WHISPER::Message msg = WHISPER::Message(getOrderingEntity().getParentNumber(), getOrderingEntity().getNumber(), WHISPER::MsgTopics::COMMANDS , WHISPER::MsgType::COMMAND , srcType); + WHISPER::Message msg = WHISPER::Message(getOwnID().getUUID(), WHISPER::MsgTopics::COMMANDS , WHISPER::MsgType::COMMAND , srcType); messages::entity::order::MoveOrder MoveOrder = messages::entity::order::MoveOrder(); - MoveOrder.mutable_geocentricposition()->set_x(pos_.getGeocentricPos().x()); - MoveOrder.mutable_geocentricposition()->set_y(pos_.getGeocentricPos().y()); - MoveOrder.mutable_geocentricposition()->set_z(pos_.getGeocentricPos().z()); - - if (speed_ != 0) { - MoveOrder.set_speed(speed_); + if (pos_.isValid()) + { + MoveOrder.mutable_geocentricposition()->set_x(pos_.getGeocentricPos().x()); + MoveOrder.mutable_geocentricposition()->set_y(pos_.getGeocentricPos().y()); + MoveOrder.mutable_geocentricposition()->set_z(pos_.getGeocentricPos().z()); } - if (startTime_ != 0) { - MoveOrder.mutable_startingtime()->set_seconds(startTime_); + if (Speed.getValidity() == true) { + MoveOrder.set_speed(Speed.getValue()); + } + if (Course.getValidity() == true) { + MoveOrder.set_course(Course.getValue()); + } + + if (StartTime.getValidity() == true) { + MoveOrder.mutable_startingtime()->set_seconds(StartTime.getValue()); } @@ -77,7 +77,7 @@ namespace Orders } - std::shared_ptr MoveOrder::unpack(WHISPER::Message msg) + std::unique_ptr MoveOrder::unpack(WHISPER::Message msg) { if(msg.msgType_ == WHISPER::MsgType::COMMAND) @@ -87,23 +87,26 @@ namespace Orders { auto order = messages::entity::order::Order(); protoMsg.payload().UnpackTo(&order); + if (order.has_orderpayload() && order.orderpayload().Is()) { auto moveOrder = messages::entity::order::MoveOrder(); order.orderpayload().UnpackTo(&moveOrder); - SimCore::Identifier OrderID(order.orderid().parent(),order.orderid().number(),order.orderid().external()); - SimCore::Identifier OrderingID(order.orderingentity().parent(),order.orderingentity().number(),order.orderingentity().external()); - SimCore::Identifier OrderedID(order.orderedentity().parent(),order.orderedentity().number(),order.orderedentity().external()); + + SimCore::Identifier OrderID(order.orderid()); - auto pos = SimCore::Position(moveOrder.geocentricposition().x(),moveOrder.geocentricposition().y(),moveOrder.geocentricposition().z()); - - auto MoveOrderObj = std::make_shared(OrderID,OrderingID,OrderedID,(WHISPER::SourceType)msg.sourceType_,pos); + auto MoveOrderObj = std::make_unique(OrderID,(WHISPER::SourceType)msg.sourceType_); + + + if (moveOrder.has_geocentricposition()) MoveOrderObj->setPosition(SimCore::Position(moveOrder.geocentricposition().x(),moveOrder.geocentricposition().y(),moveOrder.geocentricposition().z())); + + if (moveOrder.has_speed()) MoveOrderObj->Speed.setValue(moveOrder.speed()); + if (moveOrder.has_course()) MoveOrderObj->Course.setValue(moveOrder.course()); + if (moveOrder.has_startingtime()) MoveOrderObj->Course.setValue(moveOrder.mutable_startingtime()->seconds()); - MoveOrderObj->setSpeed(moveOrder.speed()); - MoveOrderObj->setStartTime(moveOrder.mutable_startingtime()->seconds()); - return MoveOrderObj; + return std::move(MoveOrderObj); } } @@ -112,5 +115,16 @@ namespace Orders return nullptr; } + std::unique_ptr MoveOrder::unpack(std::string msg) + { + if (std::empty(msg) == false && msg != "NULL") + { + WHISPER::Message whisperMessage(msg); + return std::move(unpack(whisperMessage)); + } + + return nullptr; + } + } \ No newline at end of file diff --git a/src/Orders/Order.cpp b/src/Orders/Order.cpp index bbf9e1f..c4b4d22 100644 --- a/src/Orders/Order.cpp +++ b/src/Orders/Order.cpp @@ -1,13 +1,13 @@ +#include "SimCore/Identifier.hpp" #include namespace Orders { - Order::Order(const SimCore::Identifier id,const SimCore::Identifier orderingEntity,const SimCore::Identifier orderedEntity,const WHISPER::SourceType srcType, const Orders::OrderType OrderType_): - orderID_(id), - orderingEntity_(orderingEntity), - orderedEntity_(orderedEntity), + Order::Order(const SimCore::Identifier OwnID,const WHISPER::SourceType srcType, const Orders::OrderType OrderType_): + orderID_(SimCore::Identifier()), + OwnID_(OwnID), srcType(srcType), OrderType_(OrderType_) { @@ -18,8 +18,7 @@ namespace Orders const SimCore::Identifier Order::getOrderID(){ return orderID_;} - const SimCore::Identifier Order::getOrderingEntity(){ return orderingEntity_;} - const SimCore::Identifier Order::getOrderedEntity(){ return orderedEntity_;} const Orders::OrderType Order::getOrderType(){return OrderType_;} + const SimCore::Identifier Order::getOwnID(){return OwnID_;} } \ No newline at end of file