SkillID.cpp
Go to the documentation of this file.
1#include "SkillID.h"
2
3#include <optional>
4
6
7namespace armarx
8{
9 namespace skills
10 {
11 bool
12 SkillID::operator==(const SkillID& other) const
13 {
14 return this->toString() == other.toString();
15 }
16
17 bool
18 SkillID::operator!=(const SkillID& other) const
19 {
20 return not(*this == other);
21 }
22
23 bool
24 SkillID::operator<(const SkillID& other) const
25 {
26 return toString() < other.toString();
27 }
28
29 bool
30 SkillID::operator<=(const SkillID& other) const
31 {
32 return toString() <= other.toString();
33 }
34
36 SkillID::FromIce(const manager::dto::SkillID& s)
37 {
38 return SkillID{.providerId =
39 skills::ProviderID{.providerName = s.providerId.providerName},
40 .skillName = s.skillName};
41 }
42
44 SkillID::FromIce(const provider::dto::SkillID& s,
45 const std::optional<ProviderID>& providerId)
46 {
47 if (providerId.has_value())
48 {
49 return SkillID{.providerId = *providerId, .skillName = s.skillName};
50 }
51 return SkillID{.skillName = s.skillName};
52 }
53
54 manager::dto::SkillID
56 {
57 ARMARX_CHECK(isFullySpecified()) << "Got: " << toString();
58 return {providerId->toManagerIce(), skillName};
59 }
60
61 provider::dto::SkillID
63 {
64 return {skillName};
65 }
66
67 std::string
69 {
70 if (providerId.has_value())
71 {
72 return providerId->providerName + NAME_SEPARATOR + skillName;
73 }
75 }
76
77 bool
82
83 bool
85 {
86 return not skillName.empty();
87 }
88
89 bool
91 {
92 if (not providerId.has_value())
93 {
94 return false;
95 }
96 return not providerId->providerName.empty();
97 }
98 } // namespace skills
99
100 std::ostream&
101 skills::operator<<(std::ostream& os, const SkillID& id)
102 {
103 return os << "'" << id.toString() << "'";
104 }
105} // namespace armarx
bool isProviderSpecified() const
Definition SkillID.cpp:90
std::string toString() const
Definition SkillID.cpp:68
bool operator<=(const SkillID &other) const
Definition SkillID.cpp:30
bool operator==(const SkillID &other) const
Definition SkillID.cpp:12
bool operator!=(const SkillID &other) const
Definition SkillID.cpp:18
std::optional< ProviderID > providerId
Definition SkillID.h:40
bool isFullySpecified() const
Definition SkillID.cpp:78
bool operator<(const SkillID &other) const
Definition SkillID.cpp:24
provider::dto::SkillID toProviderIce() const
Definition SkillID.cpp:62
manager::dto::SkillID toManagerIce() const
Definition SkillID.cpp:55
static const constexpr char * NAME_SEPARATOR
Definition SkillID.h:17
bool isSkillSpecified() const
Definition SkillID.cpp:84
static SkillID FromIce(const manager::dto::SkillID &)
Definition SkillID.cpp:36
std::string skillName
Definition SkillID.h:41
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
This file is part of ArmarX.
std::ostream & operator<<(std::ostream &os, const ProviderID &id)
This file offers overloads of toIce() and fromIce() functions for STL container types.