From be9be55e64ae93bbf9bab280016b7ce1ff6ae922 Mon Sep 17 00:00:00 2001 From: Tobias Klausmann Date: Tue, 12 Sep 2023 17:29:12 +0200 Subject: [PATCH] specificAssetId: Renamed for identifierkeyvaluepair Adapt properties to the new specification As the types are final, rename them according to the new specification Signed-off-by: Tobias Klausmann --- src/libaas/basyx/asset/assetinformation.h | 10 ++-- src/libaas/basyx/identifierkeyvaluepair.h | 41 ----------------- .../basyx/serialization/json/serializer.cpp | 8 ++-- .../basyx/serialization/json/serializer_fwd.h | 4 +- ...erkeyvaluepair.cpp => specificAssetId.cpp} | 0 src/libaas/basyx/specificAssetId.h | 46 +++++++++++++++++++ src/libaas/basyx/submodelelement/entity.h | 10 ++-- src/libaas/sources.cmake | 4 +- 8 files changed, 63 insertions(+), 60 deletions(-) delete mode 100644 src/libaas/basyx/identifierkeyvaluepair.h rename src/libaas/basyx/{identifierkeyvaluepair.cpp => specificAssetId.cpp} (100%) create mode 100644 src/libaas/basyx/specificAssetId.h diff --git a/src/libaas/basyx/asset/assetinformation.h b/src/libaas/basyx/asset/assetinformation.h index 8eeb3db..a8235f3 100644 --- a/src/libaas/basyx/asset/assetinformation.h +++ b/src/libaas/basyx/asset/assetinformation.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include @@ -17,7 +17,7 @@ class AssetInformation private: AssetKind assetKind; util::optional globalAssetId; - std::vector specificAssetId; + std::vector specificAssetId; util::optional assetType; util::optional defaultThumbnail; public: @@ -35,9 +35,9 @@ class AssetInformation const util::optional & getGlobalAssetId() const { return this->globalAssetId; }; void setGlobalAssetId(Identifier globalAssetId) { this->globalAssetId.emplace(std::move(globalAssetId)); }; - void addSpecificAssetId(IdentifierKeyValuePair specificAssetId) { this->specificAssetId.emplace_back(std::move(specificAssetId)); }; - const std::vector & getSpecificAssetIds() const { return this->specificAssetId; }; - std::vector & getSpecificAssetIds() { return this->specificAssetId; }; + void addSpecificAssetId(SpecificAssetId specificAssetId) { this->specificAssetId.emplace_back(std::move(specificAssetId)); }; + const std::vector & getSpecificAssetIds() const { return this->specificAssetId; }; + std::vector & getSpecificAssetIds() { return this->specificAssetId; }; const util::optional & getAssetType() const { return this->assetType; }; void setAssetType(Identifier assetType) { this->assetType.emplace(std::move(assetType)); }; diff --git a/src/libaas/basyx/identifierkeyvaluepair.h b/src/libaas/basyx/identifierkeyvaluepair.h deleted file mode 100644 index 65d5921..0000000 --- a/src/libaas/basyx/identifierkeyvaluepair.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include -#include - -#include -#include - -#include - -namespace basyx -{ - -class IdentifierKeyValuePair : public HasSemantics -{ -private: - std::string key; - util::optional value; - util::optional externalSubjectId; -public: - IdentifierKeyValuePair(util::string_view key) : key(key.to_string()) {}; - - IdentifierKeyValuePair(const IdentifierKeyValuePair&) = default; - IdentifierKeyValuePair(IdentifierKeyValuePair&&) = default; - - IdentifierKeyValuePair & operator=(const IdentifierKeyValuePair&) noexcept = default; - IdentifierKeyValuePair & operator=(IdentifierKeyValuePair&&) noexcept = default; - - ~IdentifierKeyValuePair() = default; -public: - const std::string & getKey() const { return key; }; - void setKey(util::string_view key) { this->key = key.to_string(); }; - - const util::optional & getValue() const { return this->value; }; - void setValue(util::string_view value) { this->value = value.to_string(); } - - const util::optional & getExternalSubjectId() const { return this->externalSubjectId; }; - template void setExternalSubjectId(Ref && ref) { this->externalSubjectId = std::forward(ref); }; -}; - -}; diff --git a/src/libaas/basyx/serialization/json/serializer.cpp b/src/libaas/basyx/serialization/json/serializer.cpp index e45c9c3..ee3b019 100644 --- a/src/libaas/basyx/serialization/json/serializer.cpp +++ b/src/libaas/basyx/serialization/json/serializer.cpp @@ -115,15 +115,13 @@ void serialize_helper(json_t & json, const langstringset_t & langstrings) } }; -void serialize_helper(json_t & json, const IdentifierKeyValuePair & kvPair) +void serialize_helper(json_t & json, const SpecificAssetId & kvPair) { serialize_helper_h(json, kvPair); - json["key"] = kvPair.getKey(); + json["key"] = kvPair.getName(); - json["value"] = json_t(); - if(kvPair.getValue()) - json["value"] = *kvPair.getValue(); + json["value"] = kvPair.getValue().getId(); json["subjectId"] = json_t(); if(kvPair.getExternalSubjectId()) diff --git a/src/libaas/basyx/serialization/json/serializer_fwd.h b/src/libaas/basyx/serialization/json/serializer_fwd.h index f0e1b42..163aaa6 100644 --- a/src/libaas/basyx/serialization/json/serializer_fwd.h +++ b/src/libaas/basyx/serialization/json/serializer_fwd.h @@ -12,7 +12,7 @@ namespace basyx class Referable; class Identifiable; class Identifier; - class IdentifierKeyValuePair; + class SpecificAssetId; class modeltype_base; class AssetAdministrationShell; class MultiLanguageProperty; @@ -50,7 +50,7 @@ namespace basyx::serialization::json void serialize_helper(json_t & json, const modeltype_base &); void serialize_helper(json_t & json, const AssetInformation &); void serialize_helper(json_t & json, const Identifier &); - void serialize_helper(json_t & json, const IdentifierKeyValuePair &); + void serialize_helper(json_t & json, const SpecificAssetId &); void serialize_helper(json_t & json, const AdministrativeInformation&); void serialize_helper(json_t & json, const Referable&); void serialize_helper(json_t & json, const Identifiable&); diff --git a/src/libaas/basyx/identifierkeyvaluepair.cpp b/src/libaas/basyx/specificAssetId.cpp similarity index 100% rename from src/libaas/basyx/identifierkeyvaluepair.cpp rename to src/libaas/basyx/specificAssetId.cpp diff --git a/src/libaas/basyx/specificAssetId.h b/src/libaas/basyx/specificAssetId.h new file mode 100644 index 0000000..eed0250 --- /dev/null +++ b/src/libaas/basyx/specificAssetId.h @@ -0,0 +1,46 @@ +#ifndef SPECIFICASSETID_H +#define SPECIFICASSETID_H + +#include +#include + +#include +#include + +#include +#include + +#include + +namespace basyx +{ + +class SpecificAssetId : public HasSemantics +{ +private: + LabelType name; + Identifier value; + util::optional externalSubjectId; +public: + SpecificAssetId(util::string_view name) : name(name.to_string()) {}; + + SpecificAssetId(const SpecificAssetId&) = default; + SpecificAssetId(SpecificAssetId&&) = default; + + SpecificAssetId & operator=(const SpecificAssetId&) noexcept = default; + SpecificAssetId & operator=(SpecificAssetId&&) noexcept = default; + + ~SpecificAssetId() = default; +public: + const std::string getName() const { return name.getLabel(); }; + void setName(util::string_view name) { this->name = name.to_string(); }; + + const Identifier & getValue() const { return this->value; }; + void setValue(Identifier value) { this->value = value; } + + const util::optional & getExternalSubjectId() const { return this->externalSubjectId; }; + template void setExternalSubjectId(Ref && ref) { this->externalSubjectId = std::forward(ref); }; +}; +}; + +#endif /* SPECIFICASSETID_H */ diff --git a/src/libaas/basyx/submodelelement/entity.h b/src/libaas/basyx/submodelelement/entity.h index fdfb0c2..c21b8be 100644 --- a/src/libaas/basyx/submodelelement/entity.h +++ b/src/libaas/basyx/submodelelement/entity.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include namespace basyx @@ -21,7 +21,7 @@ class Entity : statementList_t statement; EntityType entityType; util::optional globalAssetId; - util::optional specificAssetId; + util::optional specificAssetId; public: Entity(util::string_view idShort) : DataElement(idShort) {}; @@ -43,8 +43,8 @@ class Entity : statementList_t & getStatement() { return this->statement; }; void setStatement(statementList_t statement) { this->statement = std::move(statement); }; - const util::optional & getSpecificAssetId() const { return this->specificAssetId; }; - void setSpecificAssetId(IdentifierKeyValuePair specificAssetId) { this->specificAssetId = std::move(specificAssetId); }; + const util::optional & getSpecificAssetId() const { return this->specificAssetId; }; + void setSpecificAssetId(SpecificAssetId specificAssetId) { this->specificAssetId = std::move(specificAssetId); }; }; -} \ No newline at end of file +} diff --git a/src/libaas/sources.cmake b/src/libaas/sources.cmake index e925dcc..ee197c3 100644 --- a/src/libaas/sources.cmake +++ b/src/libaas/sources.cmake @@ -28,7 +28,6 @@ SET(SOURCE_FILES_BASYX_AAS ${CMAKE_CURRENT_SOURCE_DIR}/basyx/hassemantics.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/identifiable.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/identifier.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/basyx/identifierkeyvaluepair.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/key.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/labelType.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/langstringset.cpp @@ -44,6 +43,7 @@ SET(SOURCE_FILES_BASYX_AAS ${CMAKE_CURRENT_SOURCE_DIR}/basyx/serialization/private/deserializer_priv.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/serialization/xml/deserializer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/serialization/xml/xmldeserializer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/basyx/specificAssetId.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/submodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/submodelelement/annotatedrelationshipelement.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basyx/submodelelement/basicevent.cpp @@ -103,7 +103,6 @@ SET(HEADER_FILES_BASYX_AAS ${CMAKE_CURRENT_SOURCE_DIR}/basyx/hassemantics.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/identifiable.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/identifier.h - ${CMAKE_CURRENT_SOURCE_DIR}/basyx/identifierkeyvaluepair.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/key.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/labelType.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/langstringset.h @@ -127,6 +126,7 @@ SET(HEADER_FILES_BASYX_AAS ${CMAKE_CURRENT_SOURCE_DIR}/basyx/serialization/serializer.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/serialization/xml/deserializer.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/serialization/xml/xmldeserializer.h + ${CMAKE_CURRENT_SOURCE_DIR}/basyx/specificAssetId.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/submodel.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/submodelelement/annotatedrelationshipelement.h ${CMAKE_CURRENT_SOURCE_DIR}/basyx/submodelelement/basicevent.h