Skip to content

Commit

Permalink
Introduce new class LabelType
Browse files Browse the repository at this point in the history
Use MinMaxString as we have to follow size constraints:
1 <> 64

This will be used in the SpecificAssetId and Entity

Signed-off-by: Tobias Klausmann <[email protected]>
  • Loading branch information
tobijk2 committed Sep 13, 2023
1 parent 4ab00bb commit d7dfd3a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/libaas/basyx/labelType.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <basyx/labelType.h>

namespace basyx {

LabelType &LabelType::operator=(const LabelType &id) noexcept {
base::MinMaxString::operator=(id);
return *this;
}

LabelType &LabelType::operator=(const basyx::util::string_view& id) noexcept {
base::MinMaxString::operator=(id.to_string());
return *this;
}

LabelType &LabelType::operator=(const std::string& id) noexcept {
base::MinMaxString::operator=(id);
return *this;
}

std::string LabelType::getLabel() const {
return static_cast<std::string>(*this);
}

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

#include <basyx/base/minMaxString.h>
#include <basyx/util/string_view/string_view.hpp>

namespace basyx
{

class LabelType: public base::MinMaxString {
private:
static const unsigned int minLenght = 1;
static const unsigned int maxLenght = 64;
public:
LabelType(): base::MinMaxString(minLenght, maxLenght) {}
LabelType(const LabelType&) = default;
LabelType(const basyx::util::string_view &v):
base::MinMaxString(minLenght, maxLenght) {
base::MinMaxString::operator=(v.to_string());
}
LabelType(LabelType&&) = default;

LabelType& operator=(const LabelType& id) noexcept;
LabelType& operator=(const basyx::util::string_view& id) noexcept;
LabelType& operator=(const std::string& id) noexcept;
//LabelType& operator=(LabelType &) noexcept = default;

std::string getLabel() const;

~LabelType() = default;
};
};
#endif // LABELTYPE_H
2 changes: 2 additions & 0 deletions src/libaas/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SET(SOURCE_FILES_BASYX_AAS
${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
${CMAKE_CURRENT_SOURCE_DIR}/basyx/modeltype.cpp
${CMAKE_CURRENT_SOURCE_DIR}/basyx/qualifiable/qualifiable.cpp
Expand Down Expand Up @@ -104,6 +105,7 @@ SET(HEADER_FILES_BASYX_AAS
${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
${CMAKE_CURRENT_SOURCE_DIR}/basyx/modeltype.h
${CMAKE_CURRENT_SOURCE_DIR}/basyx/qualifiable/qualifiable.h
Expand Down

0 comments on commit d7dfd3a

Please sign in to comment.