Skip to content
Snippets Groups Projects
Commit df331a2b authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Unify layout, add doc, add using Base::getEntity

parent 0e9bf8bf
No related branches found
No related tags found
1 merge request!95Add introspection in RemoteGui
......@@ -29,31 +29,38 @@ namespace armarx::armem
~CoreSegment() override;
CoreSegmentPtr getEmptyCopy() const;
bool hasProviderSegment(const std::string& name) const;
ProviderSegment& getProviderSegment(const std::string& name);
const ProviderSegment& getProviderSegment(const std::string& name) const;
using EntityStorage::getEntity;
const Entity& getEntity(const MemoryID& id) const override;
virtual MemoryID update(const InternalEntityUpdate& update) override;
using EntityStorage::update;
/// Add an empty provider segment with the given name.
ProviderSegment& addProviderSegment(const std::string& name);
/// Copy and insert a provider segment.
ProviderSegment& addProviderSegment(const ProviderSegment& providerSegment);
/// Move and insert a provider segment.
ProviderSegment& addProviderSegment(ProviderSegmentPtr&& providerSegment);
/// Clear the provider segments.
void clear() override;
/// Get an cleared copy of `*this` (without provider segments).
CoreSegmentPtr getEmptyCopy() const;
public:
/// The core segment type.
aron::type::AronTypePtr type;
/// The provider segments.
std::map<std::string, ProviderSegmentPtr> providerSegments;
};
......
......@@ -30,22 +30,24 @@ namespace armarx::armem
~Memory() override;
MemoryPtr getEmptyCopy() const;
bool hasCoreSegment(const std::string& name) const;
CoreSegment& getCoreSegment(const std::string& name);
const CoreSegment& getCoreSegment(const std::string& name) const;
using EntityStorage::getEntity;
const Entity& getEntity(const MemoryID& id) const override;
// CoreSegment& addCoreSegment(const std::string& name, aron::type::AronTypePtr type);
/// Add an empty core segment with the given name.
CoreSegment& addCoreSegment(const std::string& name);
/// Copy and insert a core segment.
CoreSegment& addCoreSegment(const CoreSegment& coreSegment);
/// Move and insert a core segment.
CoreSegment& addCoreSegment(CoreSegmentPtr&& coreSegment);
/**
* @brief Add multiple core segments.
* @param The core segment names.
......@@ -56,8 +58,12 @@ namespace armarx::armem
virtual MemoryID update(const InternalEntityUpdate& update) override;
using EntityStorage::update;
/// Clear the core segments.
void clear() override;
/// Get an cleared copy of `*this` (without core segments).
MemoryPtr getEmptyCopy() const;
public:
......
......@@ -8,7 +8,7 @@
namespace armarx::armem
{
ProviderSegment::ProviderSegment(const ProviderSegment& other) : EntityStorage (other)
ProviderSegment::ProviderSegment(const ProviderSegment& other) : EntityStorage(other)
{
*this = other;
}
......@@ -38,6 +38,11 @@ namespace armarx::armem
return other;
}
bool ProviderSegment::hasEntity(const string& name) const
{
return entities.count(name) > 0;
}
Entity& ProviderSegment::getEntity(const string& name)
{
return const_cast<Entity&>(const_cast<const ProviderSegment*>(this)->getEntity(name));
......@@ -79,6 +84,11 @@ namespace armarx::armem
return it->second->update(update);
}
Entity& ProviderSegment::addEntity(const string& name)
{
return addEntity(std::make_unique<Entity>(name));
}
Entity& ProviderSegment::addEntity(const Entity& entity)
{
return addEntity(std::make_unique<Entity>(entity));
......
......@@ -29,13 +29,7 @@ namespace armarx::armem
~ProviderSegment() override;
ProviderSegmentPtr getEmptyCopy() const;
bool hasEntity(const std::string& name) const
{
return entities.count(name) > 0;
}
bool hasEntity(const std::string& name) const;
using EntityStorage::getEntity;
const Entity& getEntity(const MemoryID& id) const override;
......@@ -52,10 +46,17 @@ namespace armarx::armem
virtual MemoryID update(const InternalEntityUpdate& update) override;
using EntityStorage::update;
/// Add an empty entity with the given name.
Entity& addEntity(const std::string& name);
/// Copy and insert an entity.
Entity& addEntity(const Entity& entity);
/// Move and insert an entity.
Entity& addEntity(EntityPtr&& entity);
/// Clear the entities.
virtual void clear() override;
/// Get an cleared copy of `*this` (without entities).
ProviderSegmentPtr getEmptyCopy() const;
/**
......@@ -68,6 +69,10 @@ namespace armarx::armem
public:
/// Provider segment type.
aron::type::AronTypePtr type;
/// The entities.
std::map<std::string, EntityPtr> entities;
/**
......
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