Skip to content
Snippets Groups Projects
Commit 081d3592 authored by Firat Yusuf Duran's avatar Firat Yusuf Duran :moyai:
Browse files

change memory load of composite skills

- rename methods from loadSkills to loadCompositeSkills
- add loadCompositeSkillsOfProvider(name)
- Remove deleted skills from load
parent 2a2a6e0c
No related branches found
No related tags found
2 merge requests!458Fluxio/dev get types,!449Fluxio preliminary release
......@@ -21,6 +21,7 @@
*/
#include "SkillsMemory.h"
#include <vector>
#include <SimoxUtility/algorithm/string.h>
......@@ -241,11 +242,16 @@ namespace armarx
composedSkillCoreSegment.addSkill(skill);
}
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> SkillsMemory::loadSkills()
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> SkillsMemory::loadCompositeSkills()
{
return composedSkillCoreSegment.getSkills();
}
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> SkillsMemory::loadCompositeSkillsOfProvider(const std::string& providerName)
{
return composedSkillCoreSegment.getSkillsOfProvider(providerName);
}
void SkillsMemory::addProfile(const skills::manager::arondto::FluxioProfile& profile)
{
profileCoreSegment.addProfile(profile);
......
......@@ -114,7 +114,8 @@ namespace armarx
//****************************//
void saveSkill(const skills::manager::arondto::FluxioSkill& skillt) override;
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadSkills() override;
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkills() override;
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkillsOfProvider(const std::string& providerName) override;
void addProfile(const skills::manager::arondto::FluxioProfile& profile) override;
......
......@@ -77,9 +77,35 @@ namespace armarx::skills::segment
[&ret](const armem::wm::EntityInstance& instance)
{
auto skill = instance.dataAs<skills::manager::arondto::FluxioSkill>();
if (skill.deleted)
{
return;
}
ret.push_back(skill);
});
return ret;
}
std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
ComposedSkillLibraryCoreSegment::getSkillsOfProvider(const std::string& providerName) const
{
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> opt = getSkills();
if (!opt.has_value())
{
return std::nullopt;
}
std::vector<skills::manager::arondto::FluxioSkill> ret;
for (const auto& skill : opt.value())
{
//TODO: check if id or name should be used here
if (skill.skillProviderId.hint == providerName)
{
ret.push_back(skill);
}
}
return ret;
}
} // namespace armarx::skills::segment
#pragma once
// Base Class
#include <vector>
#include <RobotAPI/libraries/armem/server/segment/SpecializedSegment.h>
// ArmarX
......@@ -31,5 +32,6 @@ namespace armarx::skills::segment
void addSkill(const skills::manager::arondto::FluxioSkill& skill);
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> getSkills() const;
std::optional<std::vector<skills::manager::arondto::FluxioSkill>> getSkillsOfProvider(const std::string& providerName) const;
};
} // namespace armarx::skills::segment
......@@ -730,7 +730,14 @@ namespace armarx
}
std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
SkillManagerComponentPluginUser::loadSkills()
SkillManagerComponentPluginUser::loadCompositeSkills()
{
// Implemented in derived class
return {};
}
std::optional<std::vector<skills::manager::arondto::FluxioSkill>>
SkillManagerComponentPluginUser::loadCompositeSkillsOfProvider(const std::string& providerId)
{
// Implemented in derived class
return {};
......
......@@ -152,7 +152,8 @@ namespace armarx
const Ice::Current& current) override;
virtual void saveSkill(const skills::manager::arondto::FluxioSkill& skill);
virtual std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadSkills();
virtual std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkills();
virtual std::optional<std::vector<skills::manager::arondto::FluxioSkill>> loadCompositeSkillsOfProvider(const std::string& providerId);
virtual void addProfile(const skills::manager::arondto::FluxioProfile& profile);
......
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