ADD: added UUID generation as part of the identifier
This commit is contained in:
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,3 +1,7 @@
|
|||||||
[submodule "libs/whisper-com"]
|
[submodule "libs/whisper-com"]
|
||||||
path = libs/whisper-com
|
path = libs/whisper-com
|
||||||
url = ssh://git@dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/whisper-com.git
|
url = ssh://git@dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/whisper-com.git
|
||||||
|
|
||||||
|
[submodule "libs/crossguid"]
|
||||||
|
path = libs/crossguid
|
||||||
|
url = https://github.com/graeme-hill/crossguid.git
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ IF(NOT TARGET Catch2)
|
|||||||
include(libs/Catch2/contrib/Catch.cmake)
|
include(libs/Catch2/contrib/Catch.cmake)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF(NOT TARGET crossguid)
|
||||||
|
set(CROSSGUID_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
||||||
|
add_subdirectory(libs/crossguid EXCLUDE_FROM_ALL)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF(NOT TARGET eigen)
|
IF(NOT TARGET eigen)
|
||||||
set(EIGEN_BUILD_DOC OFF CACHE INTERNAL "")
|
set(EIGEN_BUILD_DOC OFF CACHE INTERNAL "")
|
||||||
add_subdirectory(libs/eigen EXCLUDE_FROM_ALL)
|
add_subdirectory(libs/eigen EXCLUDE_FROM_ALL)
|
||||||
@@ -92,6 +98,7 @@ loguru
|
|||||||
libprotobuf
|
libprotobuf
|
||||||
eigen
|
eigen
|
||||||
GeographicLib
|
GeographicLib
|
||||||
|
crossguid
|
||||||
)
|
)
|
||||||
# add_dependencies(SimCore protoc)
|
# add_dependencies(SimCore protoc)
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace SimCore {
|
namespace SimCore {
|
||||||
|
|
||||||
class Identifier{
|
class Identifier{
|
||||||
@@ -18,7 +20,13 @@ namespace SimCore {
|
|||||||
* @brief constructs an object
|
* @brief constructs an object
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Identifier(std::uint32_t parent,std::uint32_t number,bool external = false) ;
|
Identifier(std::uint32_t parent,std::uint32_t number,std::string uuid,bool external = false ) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief constructs an object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Identifier(std::uint32_t parent,std::uint32_t number,bool external = false ) ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief constructs the ID out of an string
|
* @brief constructs the ID out of an string
|
||||||
@@ -56,6 +64,8 @@ namespace SimCore {
|
|||||||
*/
|
*/
|
||||||
std::string serialize();
|
std::string serialize();
|
||||||
|
|
||||||
|
std::string getUUID() const;
|
||||||
|
|
||||||
friend bool operator==(const Identifier &lhs,const Identifier &rhs);
|
friend bool operator==(const Identifier &lhs,const Identifier &rhs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -65,5 +75,7 @@ namespace SimCore {
|
|||||||
std::uint32_t number_ = 0;
|
std::uint32_t number_ = 0;
|
||||||
/// the number of the parent, all ID from an external source the parent is the same
|
/// the number of the parent, all ID from an external source the parent is the same
|
||||||
std::uint32_t parent_ = 0;
|
std::uint32_t parent_ = 0;
|
||||||
|
|
||||||
|
std::string uuid_ = "";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace SimCore {
|
|||||||
public:
|
public:
|
||||||
IdentifierMaker();
|
IdentifierMaker();
|
||||||
|
|
||||||
std::shared_ptr<SimCore::Identifier> getNewIdentifier(std::uint32_t parent,SimCore::ObjectSource);
|
std::shared_ptr<SimCore::Identifier> getNewIdentifier(std::uint32_t parent,SimCore::ObjectSource = INTERNAL);
|
||||||
|
|
||||||
bool isInList(std::shared_ptr<SimCore::Identifier>);
|
bool isInList(std::shared_ptr<SimCore::Identifier>);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace messages {
|
|||||||
namespace track {
|
namespace track {
|
||||||
PROTOBUF_CONSTEXPR Identifier::Identifier(
|
PROTOBUF_CONSTEXPR Identifier::Identifier(
|
||||||
::_pbi::ConstantInitialized): _impl_{
|
::_pbi::ConstantInitialized): _impl_{
|
||||||
/*decltype(_impl_.parent_)*/0u
|
/*decltype(_impl_.uuid_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
||||||
|
, /*decltype(_impl_.parent_)*/0u
|
||||||
, /*decltype(_impl_.number_)*/0u
|
, /*decltype(_impl_.number_)*/0u
|
||||||
, /*decltype(_impl_.external_)*/false
|
, /*decltype(_impl_.external_)*/false
|
||||||
, /*decltype(_impl_._cached_size_)*/{}} {}
|
, /*decltype(_impl_._cached_size_)*/{}} {}
|
||||||
@@ -53,6 +54,7 @@ const uint32_t TableStruct_Identifier_2eproto::offsets[] PROTOBUF_SECTION_VARIAB
|
|||||||
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.parent_),
|
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.parent_),
|
||||||
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.number_),
|
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.number_),
|
||||||
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.external_),
|
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.external_),
|
||||||
|
PROTOBUF_FIELD_OFFSET(::messages::track::Identifier, _impl_.uuid_),
|
||||||
};
|
};
|
||||||
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
|
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
|
||||||
{ 0, -1, -1, sizeof(::messages::track::Identifier)},
|
{ 0, -1, -1, sizeof(::messages::track::Identifier)},
|
||||||
@@ -63,13 +65,13 @@ static const ::_pb::Message* const file_default_instances[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const char descriptor_table_protodef_Identifier_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
|
const char descriptor_table_protodef_Identifier_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
|
||||||
"\n\020Identifier.proto\022\016messages.track\">\n\nId"
|
"\n\020Identifier.proto\022\016messages.track\"L\n\nId"
|
||||||
"entifier\022\016\n\006parent\030\001 \001(\r\022\016\n\006number\030\002 \001(\r"
|
"entifier\022\016\n\006parent\030\001 \001(\r\022\016\n\006number\030\002 \001(\r"
|
||||||
"\022\020\n\010external\030\003 \001(\010b\006proto3"
|
"\022\020\n\010external\030\003 \001(\010\022\014\n\004uuid\030\004 \001(\tb\006proto3"
|
||||||
;
|
;
|
||||||
static ::_pbi::once_flag descriptor_table_Identifier_2eproto_once;
|
static ::_pbi::once_flag descriptor_table_Identifier_2eproto_once;
|
||||||
const ::_pbi::DescriptorTable descriptor_table_Identifier_2eproto = {
|
const ::_pbi::DescriptorTable descriptor_table_Identifier_2eproto = {
|
||||||
false, false, 106, descriptor_table_protodef_Identifier_2eproto,
|
false, false, 120, descriptor_table_protodef_Identifier_2eproto,
|
||||||
"Identifier.proto",
|
"Identifier.proto",
|
||||||
&descriptor_table_Identifier_2eproto_once, nullptr, 0, 1,
|
&descriptor_table_Identifier_2eproto_once, nullptr, 0, 1,
|
||||||
schemas, file_default_instances, TableStruct_Identifier_2eproto::offsets,
|
schemas, file_default_instances, TableStruct_Identifier_2eproto::offsets,
|
||||||
@@ -101,12 +103,21 @@ Identifier::Identifier(const Identifier& from)
|
|||||||
: ::PROTOBUF_NAMESPACE_ID::Message() {
|
: ::PROTOBUF_NAMESPACE_ID::Message() {
|
||||||
Identifier* const _this = this; (void)_this;
|
Identifier* const _this = this; (void)_this;
|
||||||
new (&_impl_) Impl_{
|
new (&_impl_) Impl_{
|
||||||
decltype(_impl_.parent_){}
|
decltype(_impl_.uuid_){}
|
||||||
|
, decltype(_impl_.parent_){}
|
||||||
, decltype(_impl_.number_){}
|
, decltype(_impl_.number_){}
|
||||||
, decltype(_impl_.external_){}
|
, decltype(_impl_.external_){}
|
||||||
, /*decltype(_impl_._cached_size_)*/{}};
|
, /*decltype(_impl_._cached_size_)*/{}};
|
||||||
|
|
||||||
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
|
_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
|
||||||
|
_impl_.uuid_.InitDefault();
|
||||||
|
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
|
_impl_.uuid_.Set("", GetArenaForAllocation());
|
||||||
|
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
|
if (!from._internal_uuid().empty()) {
|
||||||
|
_this->_impl_.uuid_.Set(from._internal_uuid(),
|
||||||
|
_this->GetArenaForAllocation());
|
||||||
|
}
|
||||||
::memcpy(&_impl_.parent_, &from._impl_.parent_,
|
::memcpy(&_impl_.parent_, &from._impl_.parent_,
|
||||||
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.external_) -
|
static_cast<size_t>(reinterpret_cast<char*>(&_impl_.external_) -
|
||||||
reinterpret_cast<char*>(&_impl_.parent_)) + sizeof(_impl_.external_));
|
reinterpret_cast<char*>(&_impl_.parent_)) + sizeof(_impl_.external_));
|
||||||
@@ -118,11 +129,16 @@ inline void Identifier::SharedCtor(
|
|||||||
(void)arena;
|
(void)arena;
|
||||||
(void)is_message_owned;
|
(void)is_message_owned;
|
||||||
new (&_impl_) Impl_{
|
new (&_impl_) Impl_{
|
||||||
decltype(_impl_.parent_){0u}
|
decltype(_impl_.uuid_){}
|
||||||
|
, decltype(_impl_.parent_){0u}
|
||||||
, decltype(_impl_.number_){0u}
|
, decltype(_impl_.number_){0u}
|
||||||
, decltype(_impl_.external_){false}
|
, decltype(_impl_.external_){false}
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
, /*decltype(_impl_._cached_size_)*/{}
|
||||||
};
|
};
|
||||||
|
_impl_.uuid_.InitDefault();
|
||||||
|
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
|
_impl_.uuid_.Set("", GetArenaForAllocation());
|
||||||
|
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier::~Identifier() {
|
Identifier::~Identifier() {
|
||||||
@@ -136,6 +152,7 @@ Identifier::~Identifier() {
|
|||||||
|
|
||||||
inline void Identifier::SharedDtor() {
|
inline void Identifier::SharedDtor() {
|
||||||
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
||||||
|
_impl_.uuid_.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Identifier::SetCachedSize(int size) const {
|
void Identifier::SetCachedSize(int size) const {
|
||||||
@@ -148,6 +165,7 @@ void Identifier::Clear() {
|
|||||||
// Prevent compiler warnings about cached_has_bits being unused
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
_impl_.uuid_.ClearToEmpty();
|
||||||
::memset(&_impl_.parent_, 0, static_cast<size_t>(
|
::memset(&_impl_.parent_, 0, static_cast<size_t>(
|
||||||
reinterpret_cast<char*>(&_impl_.external_) -
|
reinterpret_cast<char*>(&_impl_.external_) -
|
||||||
reinterpret_cast<char*>(&_impl_.parent_)) + sizeof(_impl_.external_));
|
reinterpret_cast<char*>(&_impl_.parent_)) + sizeof(_impl_.external_));
|
||||||
@@ -184,6 +202,16 @@ const char* Identifier::_InternalParse(const char* ptr, ::_pbi::ParseContext* ct
|
|||||||
} else
|
} else
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
continue;
|
continue;
|
||||||
|
// string uuid = 4;
|
||||||
|
case 4:
|
||||||
|
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
|
||||||
|
auto str = _internal_mutable_uuid();
|
||||||
|
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
||||||
|
CHK_(ptr);
|
||||||
|
CHK_(::_pbi::VerifyUTF8(str, "messages.track.Identifier.uuid"));
|
||||||
|
} else
|
||||||
|
goto handle_unusual;
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
} // switch
|
} // switch
|
||||||
@@ -231,6 +259,16 @@ uint8_t* Identifier::_InternalSerialize(
|
|||||||
target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_external(), target);
|
target = ::_pbi::WireFormatLite::WriteBoolToArray(3, this->_internal_external(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// string uuid = 4;
|
||||||
|
if (!this->_internal_uuid().empty()) {
|
||||||
|
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
||||||
|
this->_internal_uuid().data(), static_cast<int>(this->_internal_uuid().length()),
|
||||||
|
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
||||||
|
"messages.track.Identifier.uuid");
|
||||||
|
target = stream->WriteStringMaybeAliased(
|
||||||
|
4, this->_internal_uuid(), target);
|
||||||
|
}
|
||||||
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
||||||
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
|
target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
|
||||||
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
|
_internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
|
||||||
@@ -247,6 +285,13 @@ size_t Identifier::ByteSizeLong() const {
|
|||||||
// Prevent compiler warnings about cached_has_bits being unused
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
// string uuid = 4;
|
||||||
|
if (!this->_internal_uuid().empty()) {
|
||||||
|
total_size += 1 +
|
||||||
|
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
||||||
|
this->_internal_uuid());
|
||||||
|
}
|
||||||
|
|
||||||
// uint32 parent = 1;
|
// uint32 parent = 1;
|
||||||
if (this->_internal_parent() != 0) {
|
if (this->_internal_parent() != 0) {
|
||||||
total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_parent());
|
total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_parent());
|
||||||
@@ -280,6 +325,9 @@ void Identifier::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PRO
|
|||||||
uint32_t cached_has_bits = 0;
|
uint32_t cached_has_bits = 0;
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
|
if (!from._internal_uuid().empty()) {
|
||||||
|
_this->_internal_set_uuid(from._internal_uuid());
|
||||||
|
}
|
||||||
if (from._internal_parent() != 0) {
|
if (from._internal_parent() != 0) {
|
||||||
_this->_internal_set_parent(from._internal_parent());
|
_this->_internal_set_parent(from._internal_parent());
|
||||||
}
|
}
|
||||||
@@ -305,7 +353,13 @@ bool Identifier::IsInitialized() const {
|
|||||||
|
|
||||||
void Identifier::InternalSwap(Identifier* other) {
|
void Identifier::InternalSwap(Identifier* other) {
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
auto* lhs_arena = GetArenaForAllocation();
|
||||||
|
auto* rhs_arena = other->GetArenaForAllocation();
|
||||||
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
||||||
|
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
||||||
|
&_impl_.uuid_, lhs_arena,
|
||||||
|
&other->_impl_.uuid_, rhs_arena
|
||||||
|
);
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::memswap<
|
::PROTOBUF_NAMESPACE_ID::internal::memswap<
|
||||||
PROTOBUF_FIELD_OFFSET(Identifier, _impl_.external_)
|
PROTOBUF_FIELD_OFFSET(Identifier, _impl_.external_)
|
||||||
+ sizeof(Identifier::_impl_.external_)
|
+ sizeof(Identifier::_impl_.external_)
|
||||||
|
|||||||
@@ -180,10 +180,25 @@ class Identifier final :
|
|||||||
// accessors -------------------------------------------------------
|
// accessors -------------------------------------------------------
|
||||||
|
|
||||||
enum : int {
|
enum : int {
|
||||||
|
kUuidFieldNumber = 4,
|
||||||
kParentFieldNumber = 1,
|
kParentFieldNumber = 1,
|
||||||
kNumberFieldNumber = 2,
|
kNumberFieldNumber = 2,
|
||||||
kExternalFieldNumber = 3,
|
kExternalFieldNumber = 3,
|
||||||
};
|
};
|
||||||
|
// string uuid = 4;
|
||||||
|
void clear_uuid();
|
||||||
|
const std::string& uuid() const;
|
||||||
|
template <typename ArgT0 = const std::string&, typename... ArgT>
|
||||||
|
void set_uuid(ArgT0&& arg0, ArgT... args);
|
||||||
|
std::string* mutable_uuid();
|
||||||
|
PROTOBUF_NODISCARD std::string* release_uuid();
|
||||||
|
void set_allocated_uuid(std::string* uuid);
|
||||||
|
private:
|
||||||
|
const std::string& _internal_uuid() const;
|
||||||
|
inline PROTOBUF_ALWAYS_INLINE void _internal_set_uuid(const std::string& value);
|
||||||
|
std::string* _internal_mutable_uuid();
|
||||||
|
public:
|
||||||
|
|
||||||
// uint32 parent = 1;
|
// uint32 parent = 1;
|
||||||
void clear_parent();
|
void clear_parent();
|
||||||
uint32_t parent() const;
|
uint32_t parent() const;
|
||||||
@@ -219,6 +234,7 @@ class Identifier final :
|
|||||||
typedef void InternalArenaConstructable_;
|
typedef void InternalArenaConstructable_;
|
||||||
typedef void DestructorSkippable_;
|
typedef void DestructorSkippable_;
|
||||||
struct Impl_ {
|
struct Impl_ {
|
||||||
|
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr uuid_;
|
||||||
uint32_t parent_;
|
uint32_t parent_;
|
||||||
uint32_t number_;
|
uint32_t number_;
|
||||||
bool external_;
|
bool external_;
|
||||||
@@ -298,6 +314,56 @@ inline void Identifier::set_external(bool value) {
|
|||||||
// @@protoc_insertion_point(field_set:messages.track.Identifier.external)
|
// @@protoc_insertion_point(field_set:messages.track.Identifier.external)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// string uuid = 4;
|
||||||
|
inline void Identifier::clear_uuid() {
|
||||||
|
_impl_.uuid_.ClearToEmpty();
|
||||||
|
}
|
||||||
|
inline const std::string& Identifier::uuid() const {
|
||||||
|
// @@protoc_insertion_point(field_get:messages.track.Identifier.uuid)
|
||||||
|
return _internal_uuid();
|
||||||
|
}
|
||||||
|
template <typename ArgT0, typename... ArgT>
|
||||||
|
inline PROTOBUF_ALWAYS_INLINE
|
||||||
|
void Identifier::set_uuid(ArgT0&& arg0, ArgT... args) {
|
||||||
|
|
||||||
|
_impl_.uuid_.Set(static_cast<ArgT0 &&>(arg0), args..., GetArenaForAllocation());
|
||||||
|
// @@protoc_insertion_point(field_set:messages.track.Identifier.uuid)
|
||||||
|
}
|
||||||
|
inline std::string* Identifier::mutable_uuid() {
|
||||||
|
std::string* _s = _internal_mutable_uuid();
|
||||||
|
// @@protoc_insertion_point(field_mutable:messages.track.Identifier.uuid)
|
||||||
|
return _s;
|
||||||
|
}
|
||||||
|
inline const std::string& Identifier::_internal_uuid() const {
|
||||||
|
return _impl_.uuid_.Get();
|
||||||
|
}
|
||||||
|
inline void Identifier::_internal_set_uuid(const std::string& value) {
|
||||||
|
|
||||||
|
_impl_.uuid_.Set(value, GetArenaForAllocation());
|
||||||
|
}
|
||||||
|
inline std::string* Identifier::_internal_mutable_uuid() {
|
||||||
|
|
||||||
|
return _impl_.uuid_.Mutable(GetArenaForAllocation());
|
||||||
|
}
|
||||||
|
inline std::string* Identifier::release_uuid() {
|
||||||
|
// @@protoc_insertion_point(field_release:messages.track.Identifier.uuid)
|
||||||
|
return _impl_.uuid_.Release();
|
||||||
|
}
|
||||||
|
inline void Identifier::set_allocated_uuid(std::string* uuid) {
|
||||||
|
if (uuid != nullptr) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
_impl_.uuid_.SetAllocated(uuid, GetArenaForAllocation());
|
||||||
|
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
|
if (_impl_.uuid_.IsDefault()) {
|
||||||
|
_impl_.uuid_.Set("", GetArenaForAllocation());
|
||||||
|
}
|
||||||
|
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
|
// @@protoc_insertion_point(field_set_allocated:messages.track.Identifier.uuid)
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif // __GNUC__
|
#endif // __GNUC__
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ package messages.track;
|
|||||||
uint32 parent = 1;
|
uint32 parent = 1;
|
||||||
uint32 number = 2;
|
uint32 number = 2;
|
||||||
bool external = 3;
|
bool external = 3;
|
||||||
|
string uuid = 4;
|
||||||
}
|
}
|
||||||
1
libs/crossguid
Submodule
1
libs/crossguid
Submodule
Submodule libs/crossguid added at ca1bf4b810
@@ -1,9 +1,12 @@
|
|||||||
#include "SimCore/SimCore.hpp"
|
#include "SimCore/SimCore.hpp"
|
||||||
#include <SimCore/Identifier.hpp>
|
#include <SimCore/Identifier.hpp>
|
||||||
|
#include <random>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <crossguid/guid.hpp>
|
||||||
|
|
||||||
#define StringDelimiter ';'
|
#define StringDelimiter ';'
|
||||||
|
|
||||||
namespace SimCore {
|
namespace SimCore {
|
||||||
@@ -11,11 +14,20 @@ namespace SimCore {
|
|||||||
Identifier::Identifier()
|
Identifier::Identifier()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Identifier::Identifier(std::uint32_t parent,std::uint32_t number, bool external):parent_(parent),number_(number),external_(external)
|
Identifier::Identifier(std::uint32_t parent,std::uint32_t number, std::string uuid,bool external):parent_(parent),number_(number),external_(external),uuid_(uuid)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Identifier::Identifier(std::uint32_t parent,std::uint32_t number,bool external):parent_(parent),number_(number),external_(external)
|
||||||
|
{
|
||||||
|
xg::Guid g = xg::newGuid();
|
||||||
|
uuid_ = g.str();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Identifier::Identifier(std::string str)
|
Identifier::Identifier(std::string str)
|
||||||
{
|
{
|
||||||
@@ -69,9 +81,19 @@ bool Identifier::isExternal() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Identifier::getUUID() const
|
||||||
|
{
|
||||||
|
return uuid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool operator==(const Identifier &lhs,const Identifier &rhs){
|
bool operator==(const Identifier &lhs,const Identifier &rhs){
|
||||||
|
if (lhs.uuid_ == rhs.uuid_) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (lhs.number_ == rhs.number_ && lhs.external_ == rhs.external_ && lhs.parent_ == rhs.parent_) {
|
if (lhs.number_ == rhs.number_ && lhs.external_ == rhs.external_ && lhs.parent_ == rhs.parent_) {
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace SimCore {
|
|||||||
IdentifierMaker::IdentifierMaker()
|
IdentifierMaker::IdentifierMaker()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::shared_ptr<SimCore::Identifier> IdentifierMaker::getNewIdentifier(std::uint32_t parent,SimCore::ObjectSource ObjectSource){
|
std::shared_ptr<SimCore::Identifier> IdentifierMaker::getNewIdentifier(std::uint32_t parent,SimCore::ObjectSource ObjectSource ){
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(mx_);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ WHISPER::Message RadarTrack::buildMessage(SimCore::Identifier parentID)
|
|||||||
SensorTrack.mutable_entityidentifier()->set_number(this->getIdentifier().getNumber());
|
SensorTrack.mutable_entityidentifier()->set_number(this->getIdentifier().getNumber());
|
||||||
SensorTrack.mutable_entityidentifier()->set_external((uint32_t)this->getIdentifier().isExternal());
|
SensorTrack.mutable_entityidentifier()->set_external((uint32_t)this->getIdentifier().isExternal());
|
||||||
SensorTrack.mutable_entityidentifier()->set_parent(this->getIdentifier().getParentNumber());
|
SensorTrack.mutable_entityidentifier()->set_parent(this->getIdentifier().getParentNumber());
|
||||||
|
SensorTrack.mutable_entityidentifier()->set_uuid(this->getIdentifier().getUUID());
|
||||||
|
|
||||||
|
|
||||||
SensorTrack.mutable_radartrack()->CopyFrom(radarTrack);
|
SensorTrack.mutable_radartrack()->CopyFrom(radarTrack);
|
||||||
SensorTrack.mutable_timestamp()->set_seconds(time(NULL));
|
SensorTrack.mutable_timestamp()->set_seconds(time(NULL));
|
||||||
@@ -104,6 +106,8 @@ double RadarTrack::getBearing() { return bearing_; }
|
|||||||
double RadarTrack::getRange() { return range_; }
|
double RadarTrack::getRange() { return range_; }
|
||||||
SimCore::EntityKind RadarTrack::getEnvironment(){ return environemnt_; }
|
SimCore::EntityKind RadarTrack::getEnvironment(){ return environemnt_; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RadarTrack RadarTrack::unpack(WHISPER::Message msg)
|
RadarTrack RadarTrack::unpack(WHISPER::Message msg)
|
||||||
{
|
{
|
||||||
auto m = msg.getProtoMessage();
|
auto m = msg.getProtoMessage();
|
||||||
@@ -114,7 +118,11 @@ RadarTrack RadarTrack::unpack(WHISPER::Message msg)
|
|||||||
m.payload().UnpackTo(&SensortrackMsg);
|
m.payload().UnpackTo(&SensortrackMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimCore::Identifier id(SensortrackMsg.mutable_entityidentifier()->parent(),SensortrackMsg.mutable_entityidentifier()->number(),SensortrackMsg.mutable_entityidentifier()->external());
|
SimCore::Identifier id(SensortrackMsg.mutable_entityidentifier()->parent(),
|
||||||
|
SensortrackMsg.mutable_entityidentifier()->number(),
|
||||||
|
SensortrackMsg.mutable_entityidentifier()->uuid(),
|
||||||
|
SensortrackMsg.mutable_entityidentifier()->external());
|
||||||
|
|
||||||
RadarTrack track((WHISPER::SourceType)m.sourcetype(), id);
|
RadarTrack track((WHISPER::SourceType)m.sourcetype(), id);
|
||||||
|
|
||||||
if (SensortrackMsg.has_radartrack())
|
if (SensortrackMsg.has_radartrack())
|
||||||
|
|||||||
Reference in New Issue
Block a user