Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development v2 continue #18

Merged
merged 12 commits into from
Sep 19, 2023
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "administrative_information.h"
#include <basyx/administrativeInformation.h>

namespace basyx
{
Expand All @@ -9,4 +9,4 @@ AdministrativeInformation::AdministrativeInformation(util::string_view version)
AdministrativeInformation::AdministrativeInformation(util::string_view version, util::string_view revision)
: version(version.to_string()), revision(revision.to_string()) {}

};
};
57 changes: 57 additions & 0 deletions src/libaas/basyx/administrativeInformation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef ADMINISTRATIVEINFORMATION_H
#define ADMINISTRATIVEINFORMATION_H

#include <string>

#include <basyx/util/optional/optional.hpp>
#include <basyx/langstringset.h>
#include <basyx/key.h>
#include <basyx/versionRevisionType.h>
#include <basyx/reference.h>
#include <basyx/identifier.h>
#include <basyx/semantics/hasDataSpecification.h>

namespace basyx
{

class AdministrativeInformation: public HasDataSpecification
{
public:
using VersionType = basyx::VersionRevisionType;
using RevisionType = basyx::VersionRevisionType;
private:
util::optional<VersionType> version;
util::optional<RevisionType> revision;
util::optional<Reference> creator;
util::optional<Identifier> templateId;
public:
AdministrativeInformation() = default;
AdministrativeInformation(util::string_view version);
AdministrativeInformation(util::string_view version, util::string_view revision);

AdministrativeInformation(const AdministrativeInformation&) = default;
AdministrativeInformation(AdministrativeInformation&&) = default;

AdministrativeInformation & operator=(const AdministrativeInformation&) = default;
AdministrativeInformation & operator=(AdministrativeInformation&&) = default;

~AdministrativeInformation() = default;
public:
const util::optional<VersionType> getVersion() const { return version; };
void setVersion(util::string_view version) { this->version = version; };

const util::optional<RevisionType> getRevision() const { return revision; };
void setRevision(util::string_view revision) { this->revision = revision; };

const util::optional<Reference> & getCreator() const { return creator; };
void setCreator(Reference & creator) { this->creator = std::move(creator); };

const util::optional<Identifier> & getTemplateId() const { return templateId; };
void setTemplateId(Identifier templateId) {
this->templateId = std::move(templateId);
};
};

};

#endif /* ADMINISTRATIVEINFORMATION_H */
39 changes: 0 additions & 39 deletions src/libaas/basyx/administrative_information.h

This file was deleted.

14 changes: 8 additions & 6 deletions src/libaas/basyx/assetadministrationshell.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <basyx/submodel.h>
#include <basyx/reference.h>
#include <basyx/identifiable.h>
#include <basyx/semantics/hasDataSpecification.h>

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

Expand All @@ -23,8 +24,9 @@ using Security = int;
//using AssetInformation = int;
// --------------------------

class AssetAdministrationShell :
public Identifiable,
class AssetAdministrationShell :
public Identifiable,
public HasDataSpecification,
public ModelType<ModelTypes::AssetAdministrationShell>,
private Identifiable::Copyable<AssetAdministrationShell>
{
Expand All @@ -41,7 +43,7 @@ class AssetAdministrationShell :
: Identifiable(idShort, Identifier(id)), assetInformation(std::move(assetInformation)) {};
public:
AssetAdministrationShell(const AssetAdministrationShell &aas):
Identifiable(aas.getIdShort(), std::move(aas.getIdentification())),
Identifiable(aas.getIdShort(), std::move(aas.getId())),
assetInformation(aas.getAssetInformation()) {
this->submodels.append(aas.getSubmodels());

Expand All @@ -53,7 +55,7 @@ class AssetAdministrationShell :
}

AssetAdministrationShell& operator=(const AssetAdministrationShell &aas) {
this->Identifiable::setIdentification(aas.getIdentification());
this->Identifiable::setId(aas.getId());
this->getIdShort() = aas.getIdShort();
this->submodels.append(aas.getSubmodels());

Expand Down Expand Up @@ -83,8 +85,8 @@ class AssetAdministrationShell :
void setSubmodels(ElementContainer<Submodel> submodels) { this->submodels = std::move(submodels); };

// Identifiable - special purpose
void setIdentification(Token<Deserializer> t, Identifier identifier) {
this->Identifiable::setIdentification(identifier);
void setId(Token<Deserializer> t, Identifier id) {
this->Identifiable::setId(id);
}
};

Expand Down
5 changes: 4 additions & 1 deletion src/libaas/basyx/haskind.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ namespace basyx
{
class HasKind
{
private:
ModelingKind kind = ModelingKind::Instance;
public:
ModelingKind kind = ModelingKind::Instance;
void setKind(ModelingKind kind) { this->kind = kind; }
const ModelingKind getKind() const { return kind; }
};

};
12 changes: 6 additions & 6 deletions src/libaas/basyx/identifiable.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <basyx/administrative_information.h>
#include <basyx/administrativeInformation.h>
#include <basyx/identifier.h>
#include <basyx/referable.h>

Expand All @@ -15,10 +15,10 @@ class Identifiable : public Referable
{
private:
util::optional<AdministrativeInformation> administration;
Identifier identification;
Identifier id;
public:
Identifiable(util::string_view idShort, util::string_view id) : Referable(idShort), identification(id) {};
Identifiable(util::string_view idShort, Identifier identification) : Referable(idShort), identification(std::move(identification)) {};
Identifiable(util::string_view idShort, util::string_view id) : Referable(idShort), id(id) {};
Identifiable(util::string_view idShort, Identifier id) : Referable(idShort), id(std::move(id)) {};

Identifiable(const Identifiable&) = default;
Identifiable(Identifiable&&) = default;
Expand All @@ -32,8 +32,8 @@ class Identifiable : public Referable
util::optional<AdministrativeInformation> & getAdministration() { return administration; };
void setAdministration(AdministrativeInformation administrativeInformation) { this->administration = std::move(administrativeInformation); }

const Identifier & getIdentification() const { return identification; };
void setIdentification(Identifier identifier) { this->identification = std::move(identifier); };
const Identifier & getId() const { return id; };
void setId(Identifier id) { this->id = std::move(id); };
};

};
2 changes: 1 addition & 1 deletion src/libaas/basyx/semantics/conceptdescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <basyx/util/container/container.hpp>

#include <basyx/identifiable.h>
#include <basyx/semantics/hasdataspecification.h>
#include <basyx/semantics/hasDataSpecification.h>

#include <initializer_list>
#include <vector>
Expand Down
6 changes: 6 additions & 0 deletions src/libaas/basyx/semantics/hasDataSpecification.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <basyx/semantics/hasDataSpecification.h>

namespace basyx
{

};
50 changes: 50 additions & 0 deletions src/libaas/basyx/semantics/hasDataSpecification.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef HASDATASPECIFICATION_H
#define HASDATASPECIFICATION_H

#include <basyx/reference.h>

#include <basyx/base/elementvector.h>

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

namespace basyx
{

class HasDataSpecification
{
private:
ElementVector<Reference> dataSpecification;
public:
HasDataSpecification() = default;

HasDataSpecification(const HasDataSpecification&) = default;
HasDataSpecification(HasDataSpecification&&) = default;

HasDataSpecification & operator=(const HasDataSpecification&) noexcept = default;
HasDataSpecification & operator=(HasDataSpecification&&) noexcept = default;

~HasDataSpecification() = default;
public:
const ElementVector<Reference> & getDataSpecification() const {
return this->dataSpecification;
};
ElementVector<Reference> & getDataSpecification() {
return this->dataSpecification;
};

void addDataSpecification(Reference dataSpecification) {
this->dataSpecification.add(dataSpecification);
};
void addDataSpecification(util::string_view dataSpecification) {
this->dataSpecification.add(dataSpecification);
};

void setDataSpecication(ElementVector<Reference> & dataSpecification) {
this->dataSpecification = std::move(dataSpecification);
}

};

};

#endif /* HASDATASPECIFICATION_H */
Empty file.
41 changes: 0 additions & 41 deletions src/libaas/basyx/semantics/hasdataspecification.h

This file was deleted.

24 changes: 16 additions & 8 deletions src/libaas/basyx/serialization/json/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void serialize_helper(json_t & json, const HasSemantics & hasSemantics)

void serialize_helper(json_t & json, const HasKind & hasKind)
{
json["kind"] = ModelingKind_::to_string(hasKind.kind);
json["kind"] = ModelingKind_::to_string(hasKind.getKind());
};

void serialize_helper(json_t & json, const modeltype_base & modelType)
Expand Down Expand Up @@ -159,14 +159,22 @@ void serialize_helper(json_t & json, const Capability & capability)

void serialize_helper(json_t & json, const AdministrativeInformation & administrativeInformation)
{
auto & version = administrativeInformation.get_version();
auto & revision = administrativeInformation.get_revision();
auto & version = administrativeInformation.getVersion();
auto & revision = administrativeInformation.getRevision();
auto & creator = administrativeInformation.getCreator();
auto & templateId = administrativeInformation.getTemplateId();

if(version)
json["version"] = *version;
if(version)
json["version"] = version->get();

if(revision)
json["revision"] = *revision;
if(revision)
json["revision"] = revision->get();

if (creator)
json["creator"] = serialize(creator.value());

if (templateId)
json["templateId"] = serialize(templateId.value());
};

void serialize_helper(json_t & json, const ReferenceElement & ref_element)
Expand Down Expand Up @@ -239,7 +247,7 @@ void serialize_helper(json_t & json, const Identifiable & identifiable)
{
serialize_helper_h<Referable>(json, identifiable);

json["identification"] = serialize(identifiable.getIdentification());
json["identification"] = serialize(identifiable.getId());

if (identifiable.getAdministration())
json["administration"] = serialize(*identifiable.getAdministration());
Expand Down
6 changes: 3 additions & 3 deletions src/libaas/basyx/serialization/xml/xmldeserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void XMLDeSerializer::deSerializeIdentifiable(xml_node node,
xml_node ident_node = findChildByName(node, XML_identification);
if (ident_node.root()) {
Identifier ident = deSerializeIdentifier(ident_node);
metamodelElement.setIdentification(ds->getToken(), ident);
metamodelElement.setId(ds->getToken(), ident);
}
}

Expand Down Expand Up @@ -345,13 +345,13 @@ void XMLDeSerializer::deSerializeHasKind(pugi::xml_node node,
xml_node mk_node = findChildByName(node, XML_modelingKind);
if (mk_node.root()) {
std::string mk_str = deSerializeString(mk_node);
metamodelElement.kind = ModelingKind_::from_string(mk_str);
metamodelElement.setKind(ModelingKind_::from_string(mk_str));
}
/* As per spec:
* "Default for an element is that it is representing an instance."
*/
else
metamodelElement.kind = ModelingKind::Instance;
metamodelElement.setKind(ModelingKind::Instance);
}

template <typename X>
Expand Down
Loading