Skip to content

Commit

Permalink
specificAssetId: Renamed for identifierkeyvaluepair
Browse files Browse the repository at this point in the history
Adapt properties to the new specification

As the types are final, rename them according to the new specification

Signed-off-by: Tobias Klausmann <[email protected]>
  • Loading branch information
tobijk2 committed Sep 13, 2023
1 parent d7dfd3a commit 962ddb6
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 59 deletions.
10 changes: 5 additions & 5 deletions src/libaas/basyx/asset/assetinformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <basyx/submodelelement/file.h>
#include <basyx/reference.h>
#include <basyx/identifiable.h>
#include <basyx/identifierkeyvaluepair.h>
#include <basyx/specificAssetId.h>

#include <basyx/enums/AssetKind.h>

Expand All @@ -17,7 +17,7 @@ class AssetInformation
private:
AssetKind assetKind;
util::optional<Identifier> globalAssetId;
std::vector<IdentifierKeyValuePair> specificAssetId;
std::vector<SpecificAssetId> specificAssetId;
util::optional<Identifier> assetType;
util::optional<File> defaultThumbnail;
public:
Expand All @@ -35,9 +35,9 @@ class AssetInformation
const util::optional<Identifier> & 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<IdentifierKeyValuePair> & getSpecificAssetIds() const { return this->specificAssetId; };
std::vector<IdentifierKeyValuePair> & getSpecificAssetIds() { return this->specificAssetId; };
void addSpecificAssetId(SpecificAssetId specificAssetId) { this->specificAssetId.emplace_back(std::move(specificAssetId)); };
const std::vector<SpecificAssetId> & getSpecificAssetIds() const { return this->specificAssetId; };
std::vector<SpecificAssetId> & getSpecificAssetIds() { return this->specificAssetId; };

const util::optional<Identifier> & getAssetType() const { return this->assetType; };
void setAssetType(Identifier assetType) { this->assetType.emplace(std::move(assetType)); };
Expand Down
41 changes: 0 additions & 41 deletions src/libaas/basyx/identifierkeyvaluepair.h

This file was deleted.

6 changes: 2 additions & 4 deletions src/libaas/basyx/serialization/json/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HasSemantics>(json, kvPair);

json["key"] = kvPair.getKey();

json["value"] = json_t();
if(kvPair.getValue())
json["value"] = *kvPair.getValue();
json["value"] = kvPair.getValue().getId();

json["subjectId"] = json_t();
if(kvPair.getExternalSubjectId())
Expand Down
4 changes: 2 additions & 2 deletions src/libaas/basyx/serialization/json/serializer_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace basyx
class Referable;
class Identifiable;
class Identifier;
class IdentifierKeyValuePair;
class SpecificAssetId;
class modeltype_base;
class AssetAdministrationShell;
class MultiLanguageProperty;
Expand Down Expand Up @@ -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&);
Expand Down
File renamed without changes.
45 changes: 45 additions & 0 deletions src/libaas/basyx/specificAssetId.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef SPECIFICASSETID_H
#define SPECIFICASSETID_H

#include <basyx/reference.h>
#include <basyx/hassemantics.h>

#include <basyx/util/optional/optional.hpp>
#include <basyx/util/string_view/string_view.hpp>

#include <basyx/identifier.h>

#include <string>

namespace basyx
{

class SpecificAssetId : public HasSemantics
{
private:
std::string name;
Identifier value;
util::optional<Reference> 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 & getKey() const { return name; };
void setKey(util::string_view key) { this->name = key.to_string(); };

const Identifier & getValue() const { return this->value; };
void setValue(Identifier value) { this->value = value; }

const util::optional<Reference> & getExternalSubjectId() const { return this->externalSubjectId; };
template<typename Ref> void setExternalSubjectId(Ref && ref) { this->externalSubjectId = std::forward<Ref>(ref); };
};
};

#endif /* SPECIFICASSETID_H */
10 changes: 5 additions & 5 deletions src/libaas/basyx/submodelelement/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <basyx/enums/EntityType.h>
#include <basyx/submodelelement/submodelelement.h>
#include <basyx/serialization/serializable.h>
#include <basyx/identifierkeyvaluepair.h>
#include <basyx/specificAssetId.h>
#include <basyx/modeltype.h>

namespace basyx
Expand All @@ -21,7 +21,7 @@ class Entity :
statementList_t statement;
EntityType entityType;
util::optional<Reference> globalAssetId;
util::optional<IdentifierKeyValuePair> specificAssetId;
util::optional<SpecificAssetId> specificAssetId;
public:
Entity(util::string_view idShort) : DataElement(idShort) {};

Expand All @@ -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<IdentifierKeyValuePair> & getSpecificAssetId() const { return this->specificAssetId; };
void setSpecificAssetId(IdentifierKeyValuePair specificAssetId) { this->specificAssetId = std::move(specificAssetId); };
const util::optional<SpecificAssetId> & getSpecificAssetId() const { return this->specificAssetId; };
void setSpecificAssetId(SpecificAssetId specificAssetId) { this->specificAssetId = std::move(specificAssetId); };
};

}
}
4 changes: 2 additions & 2 deletions src/libaas/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 962ddb6

Please sign in to comment.