ADD: added function that gives a shared_pointer to the ID of the Track

This commit is contained in:
Henry Winkel
2023-01-10 21:10:30 +01:00
parent 5597e85b83
commit bdacd2fc01
11 changed files with 82 additions and 41 deletions

View File

@@ -9,12 +9,15 @@ namespace SimCore {
class Identifier{
public:
Identifier(int number,SimCore::ObjectSource ObjectSource);
Identifier() = default;
Identifier(int number,SimCore::ObjectSource ObjectSource) ;
Identifier(std::pair<int, SimCore::ObjectSource> id);
int getNumber();
SimCore::ObjectSource getObjectSource();
bool isExternal();
bool isValid();
std::pair<int, SimCore::ObjectSource> getPair();
@@ -22,6 +25,6 @@ namespace SimCore {
private:
SimCore::ObjectSource objectSource_;
int number_;
int number_ = 0;
};
}

View File

@@ -1,11 +1,13 @@
#pragma once
#include "SimCore/SimCore.hpp"
#include <SimCore/SimCore.hpp>
#include <condition_variable>
#include <cstddef>
#include <list>
#include <SimCore/Identifier.hpp>
#include <memory>
#include <mutex>
namespace SimCore {
@@ -23,6 +25,9 @@ namespace SimCore {
std::list<std::shared_ptr<SimCore::Identifier>> IDList_;
bool ObjectSource_;
mutable std::mutex mx_;
std::condition_variable c;

View File

@@ -25,7 +25,7 @@ namespace track {
PROTOBUF_CONSTEXPR Track_Identifier::Track_Identifier(
::_pbi::ConstantInitialized): _impl_{
/*decltype(_impl_.number_)*/int64_t{0}
, /*decltype(_impl_.external_)*/false
, /*decltype(_impl_.external_)*/0u
, /*decltype(_impl_._cached_size_)*/{}} {}
struct Track_IdentifierDefaultTypeInternal {
PROTOBUF_CONSTEXPR Track_IdentifierDefaultTypeInternal()
@@ -125,7 +125,7 @@ const char descriptor_table_protodef_Track_2eproto[] PROTOBUF_SECTION_VARIABLE(p
"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"
"external\030\002 \001(\r\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"
;
@@ -183,7 +183,7 @@ inline void Track_Identifier::SharedCtor(
(void)is_message_owned;
new (&_impl_) Impl_{
decltype(_impl_.number_){int64_t{0}}
, decltype(_impl_.external_){false}
, decltype(_impl_.external_){0u}
, /*decltype(_impl_._cached_size_)*/{}
};
}
@@ -231,10 +231,10 @@ const char* Track_Identifier::_InternalParse(const char* ptr, ::_pbi::ParseConte
} else
goto handle_unusual;
continue;
// bool external = 2;
// uint32 external = 2;
case 2:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
_impl_.external_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
_impl_.external_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
CHK_(ptr);
} else
goto handle_unusual;
@@ -274,10 +274,10 @@ uint8_t* Track_Identifier::_InternalSerialize(
target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_number(), target);
}
// bool external = 2;
// uint32 external = 2;
if (this->_internal_external() != 0) {
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_external(), target);
target = ::_pbi::WireFormatLite::WriteUInt32ToArray(2, this->_internal_external(), target);
}
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
@@ -301,9 +301,9 @@ size_t Track_Identifier::ByteSizeLong() const {
total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_number());
}
// bool external = 2;
// uint32 external = 2;
if (this->_internal_external() != 0) {
total_size += 1 + 1;
total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_external());
}
return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);

View File

@@ -201,13 +201,13 @@ class Track_Identifier final :
void _internal_set_number(int64_t value);
public:
// bool external = 2;
// uint32 external = 2;
void clear_external();
bool external() const;
void set_external(bool value);
uint32_t external() const;
void set_external(uint32_t value);
private:
bool _internal_external() const;
void _internal_set_external(bool value);
uint32_t _internal_external() const;
void _internal_set_external(uint32_t value);
public:
// @@protoc_insertion_point(class_scope:messages.track.Track.Identifier)
@@ -219,7 +219,7 @@ class Track_Identifier final :
typedef void DestructorSkippable_;
struct Impl_ {
int64_t number_;
bool external_;
uint32_t external_;
mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_;
};
union { Impl_ _impl_; };
@@ -648,22 +648,22 @@ inline void Track_Identifier::set_number(int64_t value) {
// @@protoc_insertion_point(field_set:messages.track.Track.Identifier.number)
}
// bool external = 2;
// uint32 external = 2;
inline void Track_Identifier::clear_external() {
_impl_.external_ = false;
_impl_.external_ = 0u;
}
inline bool Track_Identifier::_internal_external() const {
inline uint32_t Track_Identifier::_internal_external() const {
return _impl_.external_;
}
inline bool Track_Identifier::external() const {
inline uint32_t 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) {
inline void Track_Identifier::_internal_set_external(uint32_t value) {
_impl_.external_ = value;
}
inline void Track_Identifier::set_external(bool value) {
inline void Track_Identifier::set_external(uint32_t value) {
_internal_set_external(value);
// @@protoc_insertion_point(field_set:messages.track.Track.Identifier.external)
}

View File

@@ -19,7 +19,7 @@ message Track {
message Identifier{
int64 number = 1;
bool external = 2;
uint32 external = 2;
}
Identifier EntityIdentifier = 1;

View File

@@ -1,6 +1,7 @@
#pragma once
#include "SimCore/Identifier.hpp"
#include "google/protobuf/any.pb.h"
#include <SimCore/Position.hpp>
#include <WHISPER/Messages/Message.hpp>
@@ -37,8 +38,9 @@ namespace SimCore {
/// function that packs all information to a protobuf message
void packToMessage();
/// the unique tracknumber for now
std::uint32_t trackNo_;
/// ID of the object
SimCore::Identifier ID_;
public:
@@ -52,12 +54,13 @@ namespace SimCore {
* @brief constructor for building a track which is also the trackmessage to send
* @param uint32_t deviceID the id of the sending device
* @param WHISPER::SourceType sourcetype of the sending device
* @param uint32_t internal tracknumber
* @param bool external indicates if track is from an external source e.g. dis
* @param SimCore::Identifier object identifier
*
* @return
*/
Track(std::uint32_t deviceID, WHISPER::SourceType src,std::uint32_t trackNo, bool external);
Track(std::uint32_t deviceID, WHISPER::SourceType src,SimCore::Identifier id);
/**
* @brief set the position of the track
@@ -103,6 +106,8 @@ namespace SimCore {
/// return true if is external
bool isExternal();
std::shared_ptr<SimCore::Identifier> getIdentifier();

View File

@@ -20,9 +20,9 @@ Z
};
enum ObjectSource : std::uint8_t {
EXTERNAL = 0,
INTERNAL = 1
enum ObjectSource : std::uint32_t {
EXTERNAL = 1,
INTERNAL = 2
};