Skip to content
Snippets Groups Projects
Commit 1a46db86 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

strugled with operators. Added operator<=

parent 0f38e9df
No related branches found
No related tags found
1 merge request!388Refactor skills framework
Pipeline #15629 failed
......@@ -19,7 +19,7 @@ namespace armarx
bool
ProviderID::operator==(const ProviderID& other) const
{
return providerName == other.providerName;
return toString() == other.toString();
}
bool
......@@ -34,6 +34,12 @@ namespace armarx
return toString() < other.toString();
}
bool
ProviderID::operator<=(const ProviderID& other) const
{
return toString() <= other.toString();
}
ProviderID
ProviderID::FromIce(const manager::dto::ProviderID& s)
{
......@@ -59,9 +65,9 @@ namespace armarx
}
std::string
ProviderID::toString(const std::string& prefix) const
ProviderID::toString() const
{
return (prefix.empty() ? std::string("") : (prefix + PREFIX_SEPARATOR)) + providerName;
return providerName;
}
} // namespace skills
......
......@@ -15,10 +15,6 @@ namespace armarx
class ProviderID
{
public:
static const constexpr char* PREFIX_SEPARATOR = "->";
std::string providerName;
ProviderID() = default;
ProviderID(const skills::SkillID& skillid);
ProviderID(const std::string& pName);
......@@ -26,6 +22,7 @@ namespace armarx
bool operator==(const ProviderID& other) const;
bool operator!=(const ProviderID& other) const;
bool operator<(const ProviderID& other) const;
bool operator<=(const ProviderID& other) const;
manager::dto::ProviderID toManagerIce() const;
callback::dto::ProviderID toCallbackIce() const;
......@@ -33,7 +30,9 @@ namespace armarx
static ProviderID FromIce(const manager::dto::ProviderID&);
static ProviderID FromIce(const callback::dto::ProviderID&);
std::string toString(const std::string& prefix = "") const;
std::string toString() const;
std::string providerName;
};
std::ostream& operator<<(std::ostream& os, const ProviderID& id);
......
......@@ -160,14 +160,24 @@ namespace armarx
}
void
Skill::checkWhetherSkillShouldTerminate(const std::string& abortedMessage)
Skill::throwIfSkillShouldTerminate(const std::function<void()>& do_before,
const std::string& abortedMessage)
{
if (shouldSkillTerminate())
{
do_before();
throwIfSkillShouldTerminate(abortedMessage);
}
}
void
Skill::throwIfSkillShouldTerminate(const std::string& abortedMessage)
{
if (stopped)
{
std::string message = abortedMessage.empty()
? std::string("The skill '" + getSkillId().toString() +
"' was asked to stop.")
: abortedMessage;
std::string message =
std::string("The skill '" + getSkillId().toString() + "' was asked to stop.");
message += abortedMessage.empty() ? "" : " Additional message: " + abortedMessage;
throw error::SkillAbortedException(message);
return;
......@@ -175,10 +185,9 @@ namespace armarx
if (timeoutReached)
{
std::string message = abortedMessage.empty()
? std::string("The skill '" + getSkillId().toString() +
"' reached timeout.")
: abortedMessage;
std::string message =
std::string("The skill '" + getSkillId().toString() + "' reached timeout.");
message += abortedMessage.empty() ? "" : " Additional message: " + abortedMessage;
ARMARX_WARNING << message;
throw error::SkillFailedException(message);
......
......@@ -123,7 +123,9 @@ namespace armarx
}
protected:
void checkWhetherSkillShouldTerminate(const std::string& abortedMessage = "");
void throwIfSkillShouldTerminate(const std::string& abortedMessage = "");
void throwIfSkillShouldTerminate(const std::function<void()>& do_before,
const std::string& abortedMessage = "");
static MainResult MakeSucceededResult(aron::data::DictPtr data = nullptr);
static MainResult MakeFailedResult();
......
......@@ -25,7 +25,7 @@ namespace armarx
bool
SkillID::operator==(const SkillID& other) const
{
return providerId == other.providerId && skillName == other.skillName;
return this->toString() == other.toString();
}
bool
......@@ -40,6 +40,12 @@ namespace armarx
return toString() < other.toString();
}
bool
SkillID::operator<=(const SkillID& other) const
{
return toString() <= other.toString();
}
SkillID
SkillID::FromIce(const manager::dto::SkillID& s)
{
......
......@@ -26,6 +26,7 @@ namespace armarx
bool operator==(const SkillID& other) const;
bool operator!=(const SkillID& other) const;
bool operator<(const SkillID& other) const;
bool operator<=(const SkillID& other) const;
bool
isFullySpecified() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment