ADD: added cost do serialize function in Identifier

This commit is contained in:
Henry Winkel
2023-03-31 11:06:25 +02:00
parent dd036d9d90
commit f83fabd343
2 changed files with 7 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ namespace SimCore {
* @brief returns the serilaized string of the ID * @brief returns the serilaized string of the ID
* @brief string * @brief string
*/ */
std::string serialize(); std::string serialize() const;
std::string getUUID() const; std::string getUUID() const;
@@ -76,6 +76,6 @@ namespace SimCore {
/// 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_ = ""; std::string uuid_;
}; };
} }

View File

@@ -19,11 +19,8 @@ Identifier::Identifier(std::uint32_t parent,std::uint32_t number, std::string uu
} }
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,bool external):parent_(parent),number_(number),external_(external),uuid_(xg::newGuid().str())
{ {
xg::Guid g = xg::newGuid();
uuid_ = g.str();
} }
@@ -40,14 +37,15 @@ Identifier::Identifier(std::string str)
} }
if (UtilFunctions::isNumber(var[2])) { if (UtilFunctions::isNumber(var[2])) {
external_ = (bool)stoi(var[2]); external_ = (bool)stoi(var[2]);
}
if (var[3] != "") {
uuid_ = var[3];
} }
} }
std::string Identifier::serialize() std::string Identifier::serialize() const
{ {
return std::to_string(parent_) + StringDelimiter + std::to_string(number_) + StringDelimiter + std::to_string(external_) + StringDelimiter + uuid_; return std::to_string(parent_) + StringDelimiter + std::to_string(number_) + StringDelimiter + std::to_string(external_) + StringDelimiter + uuid_;
} }