diff --git a/CMakeLists.txt b/CMakeLists.txt index 1120163..dacf89c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,14 @@ add_library(SimCore STATIC include/SimCore/SafeMap.hpp src/SimCore/SafeMap.cpp + include/SimCore/Identifier.hpp + src/SimCore/Identifier.cpp + + include/SimCore/IdentifierMaker.hpp + src/SimCore/IdentifierMaker.cpp + + + ) @@ -97,4 +105,13 @@ IF (${TEST_SIMCORE_LIBRARY}) target_link_libraries(test_SafeMap Catch2::Catch2 SimCore loguru) catch_discover_tests(test_SafeMap) + add_executable(test_IdentifierClass tests/test_IdentifierClass.cpp) + target_link_libraries(test_IdentifierClass Catch2::Catch2 SimCore loguru) + catch_discover_tests(test_IdentifierClass) + + + add_executable(test_IdentifierList tests/test_IdentifierList.cpp) + target_link_libraries(test_IdentifierList Catch2::Catch2 SimCore loguru) + catch_discover_tests(test_IdentifierList) + ENDIF() diff --git a/include/SimCore/Identifier.hpp b/include/SimCore/Identifier.hpp new file mode 100644 index 0000000..8149231 --- /dev/null +++ b/include/SimCore/Identifier.hpp @@ -0,0 +1,27 @@ +#pragma once + + +#include "SimCore/SimCore.hpp" +#include +#include +#include +namespace SimCore { + + class Identifier{ + public: + Identifier(int number,SimCore::ObjectSource ObjectSource); + Identifier(std::pair id); + + int getNumber(); + SimCore::ObjectSource getObjectSource(); + bool isExternal(); + + std::pair getPair(); + + friend bool operator==(const Identifier &lhs,const Identifier &rhs); + + private: + SimCore::ObjectSource objectSource_; + int number_; + }; +} diff --git a/include/SimCore/IdentifierMaker.hpp b/include/SimCore/IdentifierMaker.hpp new file mode 100644 index 0000000..3f7a7b3 --- /dev/null +++ b/include/SimCore/IdentifierMaker.hpp @@ -0,0 +1,32 @@ +#pragma once + + +#include "SimCore/SimCore.hpp" +#include +#include +#include +#include + +namespace SimCore { + + class IdentifierMaker{ + public: + IdentifierMaker(); + + std::shared_ptr getNewIdentifier(SimCore::ObjectSource); + + bool isInList(std::shared_ptr); + + size_t size(); + + private: + std::list> IDList_; + bool ObjectSource_; + + + + + }; + + +} diff --git a/include/SimCore/Messages/Protos/Track.pb.cc b/include/SimCore/Messages/Protos/Track.pb.cc index 90ca7eb..1b8c1e9 100644 --- a/include/SimCore/Messages/Protos/Track.pb.cc +++ b/include/SimCore/Messages/Protos/Track.pb.cc @@ -22,6 +22,20 @@ namespace _pbi = _pb::internal; namespace messages { namespace track { +PROTOBUF_CONSTEXPR Track_Identifier::Track_Identifier( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.number_)*/int64_t{0} + , /*decltype(_impl_.external_)*/false + , /*decltype(_impl_._cached_size_)*/{}} {} +struct Track_IdentifierDefaultTypeInternal { + PROTOBUF_CONSTEXPR Track_IdentifierDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~Track_IdentifierDefaultTypeInternal() {} + union { + Track_Identifier _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Track_IdentifierDefaultTypeInternal _Track_Identifier_default_instance_; PROTOBUF_CONSTEXPR Track_EntityGeocentricPosition::Track_EntityGeocentricPosition( ::_pbi::ConstantInitialized): _impl_{ /*decltype(_impl_.x_)*/0 @@ -39,10 +53,9 @@ struct Track_EntityGeocentricPositionDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 Track_EntityGeocentricPositionDefaultTypeInternal _Track_EntityGeocentricPosition_default_instance_; PROTOBUF_CONSTEXPR Track::Track( ::_pbi::ConstantInitialized): _impl_{ - /*decltype(_impl_.geocentricposition_)*/nullptr + /*decltype(_impl_.entityidentifier_)*/nullptr + , /*decltype(_impl_.geocentricposition_)*/nullptr , /*decltype(_impl_.timestamp_)*/nullptr - , /*decltype(_impl_.trackno_)*/0u - , /*decltype(_impl_.external_)*/false , /*decltype(_impl_.speed_)*/0 , /*decltype(_impl_.course_)*/0 , /*decltype(_impl_._cached_size_)*/{}} {} @@ -57,11 +70,19 @@ struct TrackDefaultTypeInternal { PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 TrackDefaultTypeInternal _Track_default_instance_; } // namespace track } // namespace messages -static ::_pb::Metadata file_level_metadata_Track_2eproto[2]; +static ::_pb::Metadata file_level_metadata_Track_2eproto[3]; static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_Track_2eproto = nullptr; static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_Track_2eproto = nullptr; const uint32_t TableStruct_Track_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::messages::track::Track_Identifier, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::messages::track::Track_Identifier, _impl_.number_), + PROTOBUF_FIELD_OFFSET(::messages::track::Track_Identifier, _impl_.external_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::messages::track::Track_EntityGeocentricPosition, _internal_metadata_), ~0u, // no _extensions_ @@ -77,42 +98,45 @@ const uint32_t TableStruct_Track_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(pr ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.trackno_), - PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.external_), + PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.entityidentifier_), PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.geocentricposition_), PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.speed_), PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.course_), PROTOBUF_FIELD_OFFSET(::messages::track::Track, _impl_.timestamp_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, -1, -1, sizeof(::messages::track::Track_EntityGeocentricPosition)}, - { 9, -1, -1, sizeof(::messages::track::Track)}, + { 0, -1, -1, sizeof(::messages::track::Track_Identifier)}, + { 8, -1, -1, sizeof(::messages::track::Track_EntityGeocentricPosition)}, + { 17, -1, -1, sizeof(::messages::track::Track)}, }; static const ::_pb::Message* const file_default_instances[] = { + &::messages::track::_Track_Identifier_default_instance_._instance, &::messages::track::_Track_EntityGeocentricPosition_default_instance_._instance, &::messages::track::_Track_default_instance_._instance, }; const char descriptor_table_protodef_Track_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\013Track.proto\022\016messages.track\032\037google/pr" - "otobuf/timestamp.proto\"\201\002\n\005Track\022\017\n\007trac" - "kNo\030\001 \001(\r\022\020\n\010external\030\002 \001(\010\022J\n\022Geocentri" - "cPosition\030\003 \001(\0132..messages.track.Track.E" - "ntityGeocentricPosition\022\r\n\005Speed\030\004 \001(\001\022\016" - "\n\006Course\030\005 \001(\001\022-\n\ttimestamp\030\006 \001(\0132\032.goog" - "le.protobuf.Timestamp\032;\n\030EntityGeocentri" - "cPosition\022\t\n\001X\030\001 \001(\001\022\t\n\001Y\030\002 \001(\001\022\t\n\001Z\030\003 \001" - "(\001b\006proto3" + "otobuf/timestamp.proto\"\312\002\n\005Track\022:\n\020Enti" + "tyIdentifier\030\001 \001(\0132 .messages.track.Trac" + "k.Identifier\022J\n\022GeocentricPosition\030\002 \001(\013" + "2..messages.track.Track.EntityGeocentric" + "Position\022\r\n\005Speed\030\003 \001(\001\022\016\n\006Course\030\004 \001(\001\022" + "-\n\ttimestamp\030\006 \001(\0132\032.google.protobuf.Tim" + "estamp\032.\n\nIdentifier\022\016\n\006number\030\001 \001(\003\022\020\n\010" + "external\030\002 \001(\010\032;\n\030EntityGeocentricPositi" + "on\022\t\n\001X\030\001 \001(\001\022\t\n\001Y\030\002 \001(\001\022\t\n\001Z\030\003 \001(\001b\006pro" + "to3" ; static const ::_pbi::DescriptorTable* const descriptor_table_Track_2eproto_deps[1] = { &::descriptor_table_google_2fprotobuf_2ftimestamp_2eproto, }; static ::_pbi::once_flag descriptor_table_Track_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_Track_2eproto = { - false, false, 330, descriptor_table_protodef_Track_2eproto, + false, false, 403, descriptor_table_protodef_Track_2eproto, "Track.proto", - &descriptor_table_Track_2eproto_once, descriptor_table_Track_2eproto_deps, 1, 2, + &descriptor_table_Track_2eproto_once, descriptor_table_Track_2eproto_deps, 1, 3, schemas, file_default_instances, TableStruct_Track_2eproto::offsets, file_level_metadata_Track_2eproto, file_level_enum_descriptors_Track_2eproto, file_level_service_descriptors_Track_2eproto, @@ -128,6 +152,217 @@ namespace track { // =================================================================== +class Track_Identifier::_Internal { + public: +}; + +Track_Identifier::Track_Identifier(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:messages.track.Track.Identifier) +} +Track_Identifier::Track_Identifier(const Track_Identifier& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + Track_Identifier* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.number_){} + , decltype(_impl_.external_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::memcpy(&_impl_.number_, &from._impl_.number_, + static_cast(reinterpret_cast(&_impl_.external_) - + reinterpret_cast(&_impl_.number_)) + sizeof(_impl_.external_)); + // @@protoc_insertion_point(copy_constructor:messages.track.Track.Identifier) +} + +inline void Track_Identifier::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.number_){int64_t{0}} + , decltype(_impl_.external_){false} + , /*decltype(_impl_._cached_size_)*/{} + }; +} + +Track_Identifier::~Track_Identifier() { + // @@protoc_insertion_point(destructor:messages.track.Track.Identifier) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void Track_Identifier::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); +} + +void Track_Identifier::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void Track_Identifier::Clear() { +// @@protoc_insertion_point(message_clear_start:messages.track.Track.Identifier) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + ::memset(&_impl_.number_, 0, static_cast( + reinterpret_cast(&_impl_.external_) - + reinterpret_cast(&_impl_.number_)) + sizeof(_impl_.external_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* Track_Identifier::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int64 number = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _impl_.number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // bool external = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _impl_.external_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* Track_Identifier::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:messages.track.Track.Identifier) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int64 number = 1; + if (this->_internal_number() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_number(), target); + } + + // bool external = 2; + if (this->_internal_external() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_external(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:messages.track.Track.Identifier) + return target; +} + +size_t Track_Identifier::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:messages.track.Track.Identifier) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // int64 number = 1; + if (this->_internal_number() != 0) { + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_number()); + } + + // bool external = 2; + if (this->_internal_external() != 0) { + total_size += 1 + 1; + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData Track_Identifier::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + Track_Identifier::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*Track_Identifier::GetClassData() const { return &_class_data_; } + + +void Track_Identifier::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:messages.track.Track.Identifier) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (from._internal_number() != 0) { + _this->_internal_set_number(from._internal_number()); + } + if (from._internal_external() != 0) { + _this->_internal_set_external(from._internal_external()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void Track_Identifier::CopyFrom(const Track_Identifier& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:messages.track.Track.Identifier) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool Track_Identifier::IsInitialized() const { + return true; +} + +void Track_Identifier::InternalSwap(Track_Identifier* other) { + using std::swap; + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(Track_Identifier, _impl_.external_) + + sizeof(Track_Identifier::_impl_.external_) + - PROTOBUF_FIELD_OFFSET(Track_Identifier, _impl_.number_)>( + reinterpret_cast(&_impl_.number_), + reinterpret_cast(&other->_impl_.number_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata Track_Identifier::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_Track_2eproto_getter, &descriptor_table_Track_2eproto_once, + file_level_metadata_Track_2eproto[0]); +} + +// =================================================================== + class Track_EntityGeocentricPosition::_Internal { public: }; @@ -394,17 +629,22 @@ void Track_EntityGeocentricPosition::InternalSwap(Track_EntityGeocentricPosition ::PROTOBUF_NAMESPACE_ID::Metadata Track_EntityGeocentricPosition::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_Track_2eproto_getter, &descriptor_table_Track_2eproto_once, - file_level_metadata_Track_2eproto[0]); + file_level_metadata_Track_2eproto[1]); } // =================================================================== class Track::_Internal { public: + static const ::messages::track::Track_Identifier& entityidentifier(const Track* msg); static const ::messages::track::Track_EntityGeocentricPosition& geocentricposition(const Track* msg); static const ::PROTOBUF_NAMESPACE_ID::Timestamp& timestamp(const Track* msg); }; +const ::messages::track::Track_Identifier& +Track::_Internal::entityidentifier(const Track* msg) { + return *msg->_impl_.entityidentifier_; +} const ::messages::track::Track_EntityGeocentricPosition& Track::_Internal::geocentricposition(const Track* msg) { return *msg->_impl_.geocentricposition_; @@ -429,24 +669,26 @@ Track::Track(const Track& from) : ::PROTOBUF_NAMESPACE_ID::Message() { Track* const _this = this; (void)_this; new (&_impl_) Impl_{ - decltype(_impl_.geocentricposition_){nullptr} + decltype(_impl_.entityidentifier_){nullptr} + , decltype(_impl_.geocentricposition_){nullptr} , decltype(_impl_.timestamp_){nullptr} - , decltype(_impl_.trackno_){} - , decltype(_impl_.external_){} , decltype(_impl_.speed_){} , decltype(_impl_.course_){} , /*decltype(_impl_._cached_size_)*/{}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + if (from._internal_has_entityidentifier()) { + _this->_impl_.entityidentifier_ = new ::messages::track::Track_Identifier(*from._impl_.entityidentifier_); + } if (from._internal_has_geocentricposition()) { _this->_impl_.geocentricposition_ = new ::messages::track::Track_EntityGeocentricPosition(*from._impl_.geocentricposition_); } if (from._internal_has_timestamp()) { _this->_impl_.timestamp_ = new ::PROTOBUF_NAMESPACE_ID::Timestamp(*from._impl_.timestamp_); } - ::memcpy(&_impl_.trackno_, &from._impl_.trackno_, + ::memcpy(&_impl_.speed_, &from._impl_.speed_, static_cast(reinterpret_cast(&_impl_.course_) - - reinterpret_cast(&_impl_.trackno_)) + sizeof(_impl_.course_)); + reinterpret_cast(&_impl_.speed_)) + sizeof(_impl_.course_)); // @@protoc_insertion_point(copy_constructor:messages.track.Track) } @@ -455,10 +697,9 @@ inline void Track::SharedCtor( (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ - decltype(_impl_.geocentricposition_){nullptr} + decltype(_impl_.entityidentifier_){nullptr} + , decltype(_impl_.geocentricposition_){nullptr} , decltype(_impl_.timestamp_){nullptr} - , decltype(_impl_.trackno_){0u} - , decltype(_impl_.external_){false} , decltype(_impl_.speed_){0} , decltype(_impl_.course_){0} , /*decltype(_impl_._cached_size_)*/{} @@ -476,6 +717,7 @@ Track::~Track() { inline void Track::SharedDtor() { GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + if (this != internal_default_instance()) delete _impl_.entityidentifier_; if (this != internal_default_instance()) delete _impl_.geocentricposition_; if (this != internal_default_instance()) delete _impl_.timestamp_; } @@ -490,6 +732,10 @@ void Track::Clear() { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; + if (GetArenaForAllocation() == nullptr && _impl_.entityidentifier_ != nullptr) { + delete _impl_.entityidentifier_; + } + _impl_.entityidentifier_ = nullptr; if (GetArenaForAllocation() == nullptr && _impl_.geocentricposition_ != nullptr) { delete _impl_.geocentricposition_; } @@ -498,9 +744,9 @@ void Track::Clear() { delete _impl_.timestamp_; } _impl_.timestamp_ = nullptr; - ::memset(&_impl_.trackno_, 0, static_cast( + ::memset(&_impl_.speed_, 0, static_cast( reinterpret_cast(&_impl_.course_) - - reinterpret_cast(&_impl_.trackno_)) + sizeof(_impl_.course_)); + reinterpret_cast(&_impl_.speed_)) + sizeof(_impl_.course_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -510,41 +756,33 @@ const char* Track::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { uint32_t tag; ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // uint32 trackNo = 1; + // .messages.track.Track.Identifier EntityIdentifier = 1; case 1: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { - _impl_.trackno_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_entityidentifier(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // bool external = 2; + // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 2; case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { - _impl_.external_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; - // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 18)) { ptr = ctx->ParseMessage(_internal_mutable_geocentricposition(), ptr); CHK_(ptr); } else goto handle_unusual; continue; - // double Speed = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 33)) { + // double Speed = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 25)) { _impl_.speed_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); ptr += sizeof(double); } else goto handle_unusual; continue; - // double Course = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 41)) { + // double Course = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 33)) { _impl_.course_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); ptr += sizeof(double); } else @@ -587,43 +825,38 @@ uint8_t* Track::_InternalSerialize( uint32_t cached_has_bits = 0; (void) cached_has_bits; - // uint32 trackNo = 1; - if (this->_internal_trackno() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteUInt32ToArray(1, this->_internal_trackno(), target); + // .messages.track.Track.Identifier EntityIdentifier = 1; + if (this->_internal_has_entityidentifier()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::entityidentifier(this), + _Internal::entityidentifier(this).GetCachedSize(), target, stream); } - // bool external = 2; - if (this->_internal_external() != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_external(), target); - } - - // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 3; + // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 2; if (this->_internal_has_geocentricposition()) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: - InternalWriteMessage(3, _Internal::geocentricposition(this), + InternalWriteMessage(2, _Internal::geocentricposition(this), _Internal::geocentricposition(this).GetCachedSize(), target, stream); } - // double Speed = 4; + // double Speed = 3; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_speed = this->_internal_speed(); uint64_t raw_speed; memcpy(&raw_speed, &tmp_speed, sizeof(tmp_speed)); if (raw_speed != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteDoubleToArray(4, this->_internal_speed(), target); + target = ::_pbi::WireFormatLite::WriteDoubleToArray(3, this->_internal_speed(), target); } - // double Course = 5; + // double Course = 4; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_course = this->_internal_course(); uint64_t raw_course; memcpy(&raw_course, &tmp_course, sizeof(tmp_course)); if (raw_course != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteDoubleToArray(5, this->_internal_course(), target); + target = ::_pbi::WireFormatLite::WriteDoubleToArray(4, this->_internal_course(), target); } // .google.protobuf.Timestamp timestamp = 6; @@ -649,7 +882,14 @@ size_t Track::ByteSizeLong() const { // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; - // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 3; + // .messages.track.Track.Identifier EntityIdentifier = 1; + if (this->_internal_has_entityidentifier()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.entityidentifier_); + } + + // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 2; if (this->_internal_has_geocentricposition()) { total_size += 1 + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( @@ -663,17 +903,7 @@ size_t Track::ByteSizeLong() const { *_impl_.timestamp_); } - // uint32 trackNo = 1; - if (this->_internal_trackno() != 0) { - total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_trackno()); - } - - // bool external = 2; - if (this->_internal_external() != 0) { - total_size += 1 + 1; - } - - // double Speed = 4; + // double Speed = 3; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_speed = this->_internal_speed(); uint64_t raw_speed; @@ -682,7 +912,7 @@ size_t Track::ByteSizeLong() const { total_size += 1 + 8; } - // double Course = 5; + // double Course = 4; static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_course = this->_internal_course(); uint64_t raw_course; @@ -709,6 +939,10 @@ void Track::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF uint32_t cached_has_bits = 0; (void) cached_has_bits; + if (from._internal_has_entityidentifier()) { + _this->_internal_mutable_entityidentifier()->::messages::track::Track_Identifier::MergeFrom( + from._internal_entityidentifier()); + } if (from._internal_has_geocentricposition()) { _this->_internal_mutable_geocentricposition()->::messages::track::Track_EntityGeocentricPosition::MergeFrom( from._internal_geocentricposition()); @@ -717,12 +951,6 @@ void Track::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF _this->_internal_mutable_timestamp()->::PROTOBUF_NAMESPACE_ID::Timestamp::MergeFrom( from._internal_timestamp()); } - if (from._internal_trackno() != 0) { - _this->_internal_set_trackno(from._internal_trackno()); - } - if (from._internal_external() != 0) { - _this->_internal_set_external(from._internal_external()); - } static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); double tmp_speed = from._internal_speed(); uint64_t raw_speed; @@ -757,21 +985,25 @@ void Track::InternalSwap(Track* other) { ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(Track, _impl_.course_) + sizeof(Track::_impl_.course_) - - PROTOBUF_FIELD_OFFSET(Track, _impl_.geocentricposition_)>( - reinterpret_cast(&_impl_.geocentricposition_), - reinterpret_cast(&other->_impl_.geocentricposition_)); + - PROTOBUF_FIELD_OFFSET(Track, _impl_.entityidentifier_)>( + reinterpret_cast(&_impl_.entityidentifier_), + reinterpret_cast(&other->_impl_.entityidentifier_)); } ::PROTOBUF_NAMESPACE_ID::Metadata Track::GetMetadata() const { return ::_pbi::AssignDescriptors( &descriptor_table_Track_2eproto_getter, &descriptor_table_Track_2eproto_once, - file_level_metadata_Track_2eproto[1]); + file_level_metadata_Track_2eproto[2]); } // @@protoc_insertion_point(namespace_scope) } // namespace track } // namespace messages PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::messages::track::Track_Identifier* +Arena::CreateMaybeMessage< ::messages::track::Track_Identifier >(Arena* arena) { + return Arena::CreateMessageInternal< ::messages::track::Track_Identifier >(arena); +} template<> PROTOBUF_NOINLINE ::messages::track::Track_EntityGeocentricPosition* Arena::CreateMaybeMessage< ::messages::track::Track_EntityGeocentricPosition >(Arena* arena) { return Arena::CreateMessageInternal< ::messages::track::Track_EntityGeocentricPosition >(arena); diff --git a/include/SimCore/Messages/Protos/Track.pb.h b/include/SimCore/Messages/Protos/Track.pb.h index c08a21e..d6131c6 100644 --- a/include/SimCore/Messages/Protos/Track.pb.h +++ b/include/SimCore/Messages/Protos/Track.pb.h @@ -53,17 +53,180 @@ extern TrackDefaultTypeInternal _Track_default_instance_; class Track_EntityGeocentricPosition; struct Track_EntityGeocentricPositionDefaultTypeInternal; extern Track_EntityGeocentricPositionDefaultTypeInternal _Track_EntityGeocentricPosition_default_instance_; +class Track_Identifier; +struct Track_IdentifierDefaultTypeInternal; +extern Track_IdentifierDefaultTypeInternal _Track_Identifier_default_instance_; } // namespace track } // namespace messages PROTOBUF_NAMESPACE_OPEN template<> ::messages::track::Track* Arena::CreateMaybeMessage<::messages::track::Track>(Arena*); template<> ::messages::track::Track_EntityGeocentricPosition* Arena::CreateMaybeMessage<::messages::track::Track_EntityGeocentricPosition>(Arena*); +template<> ::messages::track::Track_Identifier* Arena::CreateMaybeMessage<::messages::track::Track_Identifier>(Arena*); PROTOBUF_NAMESPACE_CLOSE namespace messages { namespace track { // =================================================================== +class Track_Identifier final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:messages.track.Track.Identifier) */ { + public: + inline Track_Identifier() : Track_Identifier(nullptr) {} + ~Track_Identifier() override; + explicit PROTOBUF_CONSTEXPR Track_Identifier(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + Track_Identifier(const Track_Identifier& from); + Track_Identifier(Track_Identifier&& from) noexcept + : Track_Identifier() { + *this = ::std::move(from); + } + + inline Track_Identifier& operator=(const Track_Identifier& from) { + CopyFrom(from); + return *this; + } + inline Track_Identifier& operator=(Track_Identifier&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const Track_Identifier& default_instance() { + return *internal_default_instance(); + } + static inline const Track_Identifier* internal_default_instance() { + return reinterpret_cast( + &_Track_Identifier_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(Track_Identifier& a, Track_Identifier& b) { + a.Swap(&b); + } + inline void Swap(Track_Identifier* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(Track_Identifier* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + Track_Identifier* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const Track_Identifier& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const Track_Identifier& from) { + Track_Identifier::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(Track_Identifier* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "messages.track.Track.Identifier"; + } + protected: + explicit Track_Identifier(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kNumberFieldNumber = 1, + kExternalFieldNumber = 2, + }; + // int64 number = 1; + void clear_number(); + int64_t number() const; + void set_number(int64_t value); + private: + int64_t _internal_number() const; + void _internal_set_number(int64_t value); + public: + + // bool external = 2; + void clear_external(); + bool external() const; + void set_external(bool value); + private: + bool _internal_external() const; + void _internal_set_external(bool value); + public: + + // @@protoc_insertion_point(class_scope:messages.track.Track.Identifier) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + int64_t number_; + bool external_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_Track_2eproto; +}; +// ------------------------------------------------------------------- + class Track_EntityGeocentricPosition final : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:messages.track.Track.EntityGeocentricPosition) */ { public: @@ -112,7 +275,7 @@ class Track_EntityGeocentricPosition final : &_Track_EntityGeocentricPosition_default_instance_); } static constexpr int kIndexInFileMessages = - 0; + 1; friend void swap(Track_EntityGeocentricPosition& a, Track_EntityGeocentricPosition& b) { a.Swap(&b); @@ -282,7 +445,7 @@ class Track final : &_Track_default_instance_); } static constexpr int kIndexInFileMessages = - 1; + 2; friend void swap(Track& a, Track& b) { a.Swap(&b); @@ -352,19 +515,37 @@ class Track final : // nested types ---------------------------------------------------- + typedef Track_Identifier Identifier; typedef Track_EntityGeocentricPosition EntityGeocentricPosition; // accessors ------------------------------------------------------- enum : int { - kGeocentricPositionFieldNumber = 3, + kEntityIdentifierFieldNumber = 1, + kGeocentricPositionFieldNumber = 2, kTimestampFieldNumber = 6, - kTrackNoFieldNumber = 1, - kExternalFieldNumber = 2, - kSpeedFieldNumber = 4, - kCourseFieldNumber = 5, + kSpeedFieldNumber = 3, + kCourseFieldNumber = 4, }; - // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 3; + // .messages.track.Track.Identifier EntityIdentifier = 1; + bool has_entityidentifier() const; + private: + bool _internal_has_entityidentifier() const; + public: + void clear_entityidentifier(); + const ::messages::track::Track_Identifier& entityidentifier() const; + PROTOBUF_NODISCARD ::messages::track::Track_Identifier* release_entityidentifier(); + ::messages::track::Track_Identifier* mutable_entityidentifier(); + void set_allocated_entityidentifier(::messages::track::Track_Identifier* entityidentifier); + private: + const ::messages::track::Track_Identifier& _internal_entityidentifier() const; + ::messages::track::Track_Identifier* _internal_mutable_entityidentifier(); + public: + void unsafe_arena_set_allocated_entityidentifier( + ::messages::track::Track_Identifier* entityidentifier); + ::messages::track::Track_Identifier* unsafe_arena_release_entityidentifier(); + + // .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 2; bool has_geocentricposition() const; private: bool _internal_has_geocentricposition() const; @@ -400,25 +581,7 @@ class Track final : ::PROTOBUF_NAMESPACE_ID::Timestamp* timestamp); ::PROTOBUF_NAMESPACE_ID::Timestamp* unsafe_arena_release_timestamp(); - // uint32 trackNo = 1; - void clear_trackno(); - uint32_t trackno() const; - void set_trackno(uint32_t value); - private: - uint32_t _internal_trackno() const; - void _internal_set_trackno(uint32_t value); - public: - - // bool external = 2; - void clear_external(); - bool external() const; - void set_external(bool value); - private: - bool _internal_external() const; - void _internal_set_external(bool value); - public: - - // double Speed = 4; + // double Speed = 3; void clear_speed(); double speed() const; void set_speed(double value); @@ -427,7 +590,7 @@ class Track final : void _internal_set_speed(double value); public: - // double Course = 5; + // double Course = 4; void clear_course(); double course() const; void set_course(double value); @@ -444,10 +607,9 @@ class Track final : typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; struct Impl_ { + ::messages::track::Track_Identifier* entityidentifier_; ::messages::track::Track_EntityGeocentricPosition* geocentricposition_; ::PROTOBUF_NAMESPACE_ID::Timestamp* timestamp_; - uint32_t trackno_; - bool external_; double speed_; double course_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; @@ -464,6 +626,50 @@ class Track final : #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" #endif // __GNUC__ +// Track_Identifier + +// int64 number = 1; +inline void Track_Identifier::clear_number() { + _impl_.number_ = int64_t{0}; +} +inline int64_t Track_Identifier::_internal_number() const { + return _impl_.number_; +} +inline int64_t Track_Identifier::number() const { + // @@protoc_insertion_point(field_get:messages.track.Track.Identifier.number) + return _internal_number(); +} +inline void Track_Identifier::_internal_set_number(int64_t value) { + + _impl_.number_ = value; +} +inline void Track_Identifier::set_number(int64_t value) { + _internal_set_number(value); + // @@protoc_insertion_point(field_set:messages.track.Track.Identifier.number) +} + +// bool external = 2; +inline void Track_Identifier::clear_external() { + _impl_.external_ = false; +} +inline bool Track_Identifier::_internal_external() const { + return _impl_.external_; +} +inline bool Track_Identifier::external() const { + // @@protoc_insertion_point(field_get:messages.track.Track.Identifier.external) + return _internal_external(); +} +inline void Track_Identifier::_internal_set_external(bool value) { + + _impl_.external_ = value; +} +inline void Track_Identifier::set_external(bool value) { + _internal_set_external(value); + // @@protoc_insertion_point(field_set:messages.track.Track.Identifier.external) +} + +// ------------------------------------------------------------------- + // Track_EntityGeocentricPosition // double X = 1; @@ -530,47 +736,97 @@ inline void Track_EntityGeocentricPosition::set_z(double value) { // Track -// uint32 trackNo = 1; -inline void Track::clear_trackno() { - _impl_.trackno_ = 0u; +// .messages.track.Track.Identifier EntityIdentifier = 1; +inline bool Track::_internal_has_entityidentifier() const { + return this != internal_default_instance() && _impl_.entityidentifier_ != nullptr; } -inline uint32_t Track::_internal_trackno() const { - return _impl_.trackno_; +inline bool Track::has_entityidentifier() const { + return _internal_has_entityidentifier(); } -inline uint32_t Track::trackno() const { - // @@protoc_insertion_point(field_get:messages.track.Track.trackNo) - return _internal_trackno(); +inline void Track::clear_entityidentifier() { + if (GetArenaForAllocation() == nullptr && _impl_.entityidentifier_ != nullptr) { + delete _impl_.entityidentifier_; + } + _impl_.entityidentifier_ = nullptr; } -inline void Track::_internal_set_trackno(uint32_t value) { +inline const ::messages::track::Track_Identifier& Track::_internal_entityidentifier() const { + const ::messages::track::Track_Identifier* p = _impl_.entityidentifier_; + return p != nullptr ? *p : reinterpret_cast( + ::messages::track::_Track_Identifier_default_instance_); +} +inline const ::messages::track::Track_Identifier& Track::entityidentifier() const { + // @@protoc_insertion_point(field_get:messages.track.Track.EntityIdentifier) + return _internal_entityidentifier(); +} +inline void Track::unsafe_arena_set_allocated_entityidentifier( + ::messages::track::Track_Identifier* entityidentifier) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.entityidentifier_); + } + _impl_.entityidentifier_ = entityidentifier; + if (entityidentifier) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:messages.track.Track.EntityIdentifier) +} +inline ::messages::track::Track_Identifier* Track::release_entityidentifier() { - _impl_.trackno_ = value; + ::messages::track::Track_Identifier* temp = _impl_.entityidentifier_; + _impl_.entityidentifier_ = 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 void Track::set_trackno(uint32_t value) { - _internal_set_trackno(value); - // @@protoc_insertion_point(field_set:messages.track.Track.trackNo) +inline ::messages::track::Track_Identifier* Track::unsafe_arena_release_entityidentifier() { + // @@protoc_insertion_point(field_release:messages.track.Track.EntityIdentifier) + + ::messages::track::Track_Identifier* temp = _impl_.entityidentifier_; + _impl_.entityidentifier_ = nullptr; + return temp; +} +inline ::messages::track::Track_Identifier* Track::_internal_mutable_entityidentifier() { + + if (_impl_.entityidentifier_ == nullptr) { + auto* p = CreateMaybeMessage<::messages::track::Track_Identifier>(GetArenaForAllocation()); + _impl_.entityidentifier_ = p; + } + return _impl_.entityidentifier_; +} +inline ::messages::track::Track_Identifier* Track::mutable_entityidentifier() { + ::messages::track::Track_Identifier* _msg = _internal_mutable_entityidentifier(); + // @@protoc_insertion_point(field_mutable:messages.track.Track.EntityIdentifier) + return _msg; +} +inline void Track::set_allocated_entityidentifier(::messages::track::Track_Identifier* entityidentifier) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete _impl_.entityidentifier_; + } + if (entityidentifier) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(entityidentifier); + if (message_arena != submessage_arena) { + entityidentifier = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, entityidentifier, submessage_arena); + } + + } else { + + } + _impl_.entityidentifier_ = entityidentifier; + // @@protoc_insertion_point(field_set_allocated:messages.track.Track.EntityIdentifier) } -// bool external = 2; -inline void Track::clear_external() { - _impl_.external_ = false; -} -inline bool Track::_internal_external() const { - return _impl_.external_; -} -inline bool Track::external() const { - // @@protoc_insertion_point(field_get:messages.track.Track.external) - return _internal_external(); -} -inline void Track::_internal_set_external(bool value) { - - _impl_.external_ = value; -} -inline void Track::set_external(bool value) { - _internal_set_external(value); - // @@protoc_insertion_point(field_set:messages.track.Track.external) -} - -// .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 3; +// .messages.track.Track.EntityGeocentricPosition GeocentricPosition = 2; inline bool Track::_internal_has_geocentricposition() const { return this != internal_default_instance() && _impl_.geocentricposition_ != nullptr; } @@ -660,7 +916,7 @@ inline void Track::set_allocated_geocentricposition(::messages::track::Track_Ent // @@protoc_insertion_point(field_set_allocated:messages.track.Track.GeocentricPosition) } -// double Speed = 4; +// double Speed = 3; inline void Track::clear_speed() { _impl_.speed_ = 0; } @@ -680,7 +936,7 @@ inline void Track::set_speed(double value) { // @@protoc_insertion_point(field_set:messages.track.Track.Speed) } -// double Course = 5; +// double Course = 4; inline void Track::clear_course() { _impl_.course_ = 0; } @@ -790,6 +1046,8 @@ inline void Track::set_allocated_timestamp(::PROTOBUF_NAMESPACE_ID::Timestamp* t #endif // __GNUC__ // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) diff --git a/include/SimCore/Messages/Protos/Track.proto b/include/SimCore/Messages/Protos/Track.proto index 840930c..237bee1 100644 --- a/include/SimCore/Messages/Protos/Track.proto +++ b/include/SimCore/Messages/Protos/Track.proto @@ -9,23 +9,29 @@ import "google/protobuf/timestamp.proto"; // [START messages] message Track { - uint32 trackNo = 1; - bool external = 2; + // uint32 trackNo = 1; + // bool external = 2; // message DISEntityID { // uint32 site = 1; // uint32 application = 2; // uint32 entity = 3; // } + message Identifier{ + int64 number = 1; + bool external = 2; + } + Identifier EntityIdentifier = 1; + message EntityGeocentricPosition { double X = 1; double Y = 2; double Z = 3; } - EntityGeocentricPosition GeocentricPosition = 3; - double Speed = 4; - double Course = 5; + EntityGeocentricPosition GeocentricPosition = 2; + double Speed = 3; + double Course = 4; // DISEntityID EntityID = 2; diff --git a/include/SimCore/SimCore.hpp b/include/SimCore/SimCore.hpp index b8f6493..c500cf3 100644 --- a/include/SimCore/SimCore.hpp +++ b/include/SimCore/SimCore.hpp @@ -20,5 +20,11 @@ Z }; +enum ObjectSource : std::uint8_t { +EXTERNAL = 0, +INTERNAL = 1 + +}; + } \ No newline at end of file diff --git a/src/SimCore/Identifier.cpp b/src/SimCore/Identifier.cpp new file mode 100644 index 0000000..f10f0d0 --- /dev/null +++ b/src/SimCore/Identifier.cpp @@ -0,0 +1,52 @@ +#include "SimCore/SimCore.hpp" +#include +#include + + + +namespace SimCore { + +Identifier::Identifier(int number, SimCore::ObjectSource ObjectSource):number_(number),objectSource_(ObjectSource) +{ + +} + +Identifier::Identifier(std::pair id):number_(id.first),objectSource_(id.second) +{ + +} + +int Identifier::getNumber() +{ + return number_; +} + +bool Identifier::isExternal() +{ + if (objectSource_ == SimCore::EXTERNAL) { + return true; + }else { + return false; + } +} + +std::pair Identifier::getPair() +{ + + return std::pair(number_,objectSource_); +} + + bool operator==(const Identifier &lhs,const Identifier &rhs){ + if (lhs.number_ == rhs.number_ && lhs.objectSource_ == rhs.objectSource_) { + return true; + }else{ + return false; + } +} + +SimCore::ObjectSource Identifier::getObjectSource() +{ + return objectSource_; +} + +} \ No newline at end of file diff --git a/src/SimCore/IdentifierMaker.cpp b/src/SimCore/IdentifierMaker.cpp new file mode 100644 index 0000000..833dfbe --- /dev/null +++ b/src/SimCore/IdentifierMaker.cpp @@ -0,0 +1,51 @@ +#include "SimCore/SimCore.hpp" +#include +#include +#include + + +namespace SimCore { + +IdentifierMaker::IdentifierMaker(){} + +std::shared_ptr IdentifierMaker::getNewIdentifier(SimCore::ObjectSource ObjectSource){ + + long size = IDList_.size(); + + int lastNumber = 0; + if (size > 0) { + for (std::list>::iterator it=IDList_.begin(); it != IDList_.end(); ++it){ + if (ObjectSource == it->get()->getObjectSource()) { + lastNumber = it->get()->getNumber(); + } + } + + int newNumber = lastNumber+1; + + auto id_ = std::make_shared(newNumber,ObjectSource); + IDList_.push_back(id_); + return id_; + + }else{ + auto id_ = std::make_shared(1,ObjectSource); + IDList_.push_back(id_); + return id_; + } + +} + +bool IdentifierMaker::isInList(std::shared_ptr ID){ + for (std::list>::iterator it=IDList_.begin(); it != IDList_.end(); ++it){ + if (ID.get() == it->get()) { + return true; + } + } + return false; +} + +size_t IdentifierMaker::size(){ + return IDList_.size(); +} + + +} \ No newline at end of file diff --git a/src/SimCore/Messages/Track.cpp b/src/SimCore/Messages/Track.cpp index f54bb93..35d6323 100644 --- a/src/SimCore/Messages/Track.cpp +++ b/src/SimCore/Messages/Track.cpp @@ -28,10 +28,14 @@ namespace SimCore { } } - trackNo_ = trackMessage.trackno(); + messages::track::Track_Identifier ID = trackMessage.entityidentifier(); + + trackNo_ = trackMessage.mutable_entityidentifier()->number(); + external_ = trackMessage.mutable_entityidentifier()->external(); + // trackNo_ = trackMessage.trackno(); + // external_ = trackMessage.external(); speed_ = trackMessage.speed(); course_ = trackMessage.course(); - external_ = trackMessage.external(); messages::track::Track_EntityGeocentricPosition pos_temp = trackMessage.geocentricposition(); position_.setGeocentricPos(pos_temp.x(), pos_temp.y(),pos_temp.z()); @@ -62,10 +66,14 @@ namespace SimCore { trackMessage_.mutable_geocentricposition()->set_y(position_.getGeocentricPos()(SimCore::Y)); trackMessage_.mutable_geocentricposition()->set_z(position_.getGeocentricPos()(SimCore::Z)); - trackMessage_.set_trackno(trackNo_); + + trackMessage_.mutable_entityidentifier()->set_external(external_); + trackMessage_.mutable_entityidentifier()->set_number(trackNo_); + + // trackMessage_.set_trackno(trackNo_); + // trackMessage_.set_external(external_); trackMessage_.set_speed(speed_); trackMessage_.set_course(course_); - trackMessage_.set_external(external_); trackMessage_.mutable_timestamp()->set_seconds(time(NULL)); diff --git a/tests/test_IdentifierClass.cpp b/tests/test_IdentifierClass.cpp new file mode 100644 index 0000000..dc71a60 --- /dev/null +++ b/tests/test_IdentifierClass.cpp @@ -0,0 +1,40 @@ +#include "SimCore/Identifier.hpp" +#include +#define CATCH_CONFIG_MAIN +#include + + + + +SCENARIO("Testing the SimCorePositionClass") +{ + GIVEN("different position in different forms") + { + + SimCore::Identifier ID1(100,SimCore::ObjectSource::EXTERNAL); + SimCore::Identifier ID2(100,SimCore::ObjectSource::EXTERNAL); + SimCore::Identifier ID3(100,SimCore::ObjectSource::INTERNAL); + SimCore::Identifier ID4(200,SimCore::ObjectSource::INTERNAL); + + + WHEN("constructing Position Object with data") + { + + THEN("positions attributes are correct") + { + REQUIRE(ID1.getNumber() == 100); + REQUIRE(ID1.isExternal() == true); + REQUIRE(ID1.getPair().first == 100); + REQUIRE(ID1.getPair().second == true); + + REQUIRE(ID1 == ID2); + REQUIRE(ID1 != ID3); + REQUIRE(ID4 != ID3); + + + + + } //THEN + } // WHEN + } // GIVEN +} //SCENARIO \ No newline at end of file diff --git a/tests/test_IdentifierList.cpp b/tests/test_IdentifierList.cpp new file mode 100644 index 0000000..9e983ff --- /dev/null +++ b/tests/test_IdentifierList.cpp @@ -0,0 +1,48 @@ +#include "SimCore/Identifier.hpp" +#include "SimCore/IdentifierMaker.hpp" +#include +#include +#define CATCH_CONFIG_MAIN +#include + +#include + + +SCENARIO("Testing the SimCorePositionClass") +{ + GIVEN("different position in different forms") + { + +SimCore::IdentifierMaker IDList; + auto ID1 = IDList.getNewIdentifier(SimCore::EXTERNAL); + auto ID2 = IDList.getNewIdentifier(SimCore::EXTERNAL); + auto ID3 = IDList.getNewIdentifier(SimCore::EXTERNAL); + + auto ID4 = IDList.getNewIdentifier(SimCore::INTERNAL); + auto ID5 = std::make_shared(100, SimCore::EXTERNAL); + + WHEN("constructing Position Object with data") + { + + THEN("positions attributes are correct") + { + REQUIRE(ID1 != ID2); + REQUIRE(ID1 != ID3); + REQUIRE(ID2 != ID3); + REQUIRE(ID1 != ID4); + REQUIRE(IDList.isInList(ID4) == true); + REQUIRE(IDList.isInList(ID5) == false); + REQUIRE(IDList.size() > 3); + REQUIRE(IDList.size() == 4); + + + + + + + + + } //THEN + } // WHEN + } // GIVEN +} //SCENARIO \ No newline at end of file