Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • sw/armarx/robot-api
  • uwkce_singer/robot-api
  • untcg_hofmann/robot-api
  • ulqba_korosakov/RobotAPI
4 results
Show changes
Commits on Source (26)
Showing
with 932 additions and 652 deletions
......@@ -76,3 +76,5 @@ etc/python/dist/*
data/RobotAPI/ArVizStorage/
.vscode/
.clang-format
.clang-tidy
......@@ -22,6 +22,7 @@
#include "ArVizStorage.h"
#include <ArmarXCore/core/logging/Logging.h>
#include <ArmarXCore/core/util/IceBlobToObject.h>
#include <ArmarXCore/core/util/ObjectToIceBlob.h>
#include <ArmarXCore/core/system/ArmarXDataPath.h>
......@@ -138,6 +139,15 @@ namespace armarx
for (auto& update : updates)
{
if (update.component.empty())
{
ARMARX_INFO << deactivateSpam(120)
<< "Discarding ArViz update with empty component name. Check whether "
<< "you correctly create your ArViz client (`armarx::viz::Client`) "
<< "in your code.";
continue;
}
auto& historyEntry = history.emplace_back();
historyEntry.revision = revision;
historyEntry.timestampInMicroseconds = nowInMicroSeconds;
......
......@@ -28,6 +28,7 @@ Client::Client(ManagedIceObject& obj,
std::string const& storageName)
{
componentName = obj.getName();
ARMARX_CHECK_NOT_EMPTY(componentName) << "ArViz client must be created with non-empty component name.";
obj.getTopic(topic, topicName);
obj.getProxy(storage, storageName);
}
......@@ -35,6 +36,7 @@ Client::Client(ManagedIceObject& obj,
Client Client::createFromTopic(std::string const& componentName, Topic::ProxyType const& topic)
{
Client client;
ARMARX_CHECK_NOT_EMPTY(componentName);
client.componentName = componentName;
client.topic = topic;
return client;
......@@ -68,6 +70,13 @@ Client Client::createForGuiPlugin(Component& component,
return client;
}
Layer Client::layer(const std::string &name) const
{
ARMARX_CHECK_NOT_EMPTY(componentName) << "Layers must be created with non-empty component name.";
ARMARX_CHECK_NOT_EMPTY(name) << "Layers must be created with non-empty layer name.";
return Layer(componentName, name);
}
CommitResult Client::commit(const StagedCommit& commit)
{
CommitResult result;
......
......@@ -130,10 +130,7 @@ namespace viz
std::string const& topicName = "ArVizTopic",
std::string const& storageName = "ArVizStorage");
Layer layer(std::string const& name) const
{
return Layer(componentName, name);
}
Layer layer(std::string const& name) const;
StagedCommit stage()
{
......
......@@ -2,19 +2,19 @@
#include "SkillProviderExample.h"
#include <RobotAPI/components/skills/SkillProviderExample/aron/HelloWorldAcceptedType.aron.generated.h>
#include <RobotAPI/libraries/aron/converter/json/NLohmannJSONConverter.h>
#include <RobotAPI/libraries/aron/core/type/variant/container/Object.h>
#include <RobotAPI/libraries/aron/core/type/variant/primitive/String.h>
#include <RobotAPI/libraries/aron/converter/json/NLohmannJSONConverter.h>
#include <RobotAPI/components/skills/SkillProviderExample/aron/HelloWorldAcceptedType.aron.generated.h>
namespace armarx::skills::provider
{
HelloWorldSkill::HelloWorldSkill() :
Skill(GetSkillDescription())
{}
HelloWorldSkill::HelloWorldSkill() : Skill(GetSkillDescription())
{
}
SkillDescription HelloWorldSkill::GetSkillDescription()
SkillDescription
HelloWorldSkill::GetSkillDescription()
{
armarx::skills::Example::HelloWorldAcceptedType default_params;
default_params.some_float = 5;
......@@ -23,41 +23,43 @@ namespace armarx::skills::provider
default_params.some_list_of_matrices.push_back(Eigen::Matrix3f::Zero());
//default_params.some_matrix = Eigen::Matrix3f::Zero();
return SkillDescription{
"HelloWorld",
"This skill logs a message on ARMARX_IMPORTANT",
{},
armarx::core::time::Duration::MilliSeconds(1000),
armarx::skills::Example::HelloWorldAcceptedType::ToAronType(),
default_params.toAron()
};
return SkillDescription{"HelloWorld",
"This skill logs a message on ARMARX_IMPORTANT",
{},
armarx::core::time::Duration::MilliSeconds(1000),
armarx::skills::Example::HelloWorldAcceptedType::ToAronType(),
default_params.toAron()};
}
Skill::MainResult HelloWorldSkill::main(const MainInput& in)
Skill::MainResult
HelloWorldSkill::main(const MainInput& in)
{
ARMARX_IMPORTANT << "Hi, from the Hello World Skill.\n" <<
"I received the following data: \n" <<
aron::converter::AronNlohmannJSONConverter::ConvertToNlohmannJSON(in.params).dump(2) << "\n" <<
"(executed at: " << IceUtil::Time::now() << ")";
ARMARX_IMPORTANT << "Hi, from the Hello World Skill.\n"
<< "I received the following data: \n"
<< aron::data::converter::AronNlohmannJSONConverter::ConvertToNlohmannJSON(
in.params)
.dump(2)
<< "\n"
<< "(executed at: " << IceUtil::Time::now() << ")";
return {TerminatedSkillStatus::Succeeded, nullptr};
}
ChainingSkill::ChainingSkill() :
Skill(GetSkillDescription())
{}
ChainingSkill::ChainingSkill() : Skill(GetSkillDescription())
{
}
SkillDescription ChainingSkill::GetSkillDescription()
SkillDescription
ChainingSkill::GetSkillDescription()
{
return SkillDescription{
"ChainingSkill",
"This skill calls the HelloWorld skill three times.",
{},
armarx::core::time::Duration::MilliSeconds(3000),
nullptr
};
return SkillDescription{"ChainingSkill",
"This skill calls the HelloWorld skill three times.",
{},
armarx::core::time::Duration::MilliSeconds(3000),
nullptr};
}
Skill::MainResult ChainingSkill::main(const MainInput& in)
Skill::MainResult
ChainingSkill::main(const MainInput& in)
{
armarx::skills::Example::HelloWorldAcceptedType exec1;
armarx::skills::Example::HelloWorldAcceptedType exec2;
......@@ -78,20 +80,21 @@ namespace armarx::skills::provider
TimeoutSkill::TimeoutSkill() :
PeriodicSkill(GetSkillDescription(), armarx::core::time::Frequency::Hertz(5))
{}
{
}
SkillDescription TimeoutSkill::GetSkillDescription()
SkillDescription
TimeoutSkill::GetSkillDescription()
{
return SkillDescription{
"Timeout",
"This fails with timeout reached",
{},
armarx::core::time::Duration::MilliSeconds(1000),
nullptr
};
return SkillDescription{"Timeout",
"This fails with timeout reached",
{},
armarx::core::time::Duration::MilliSeconds(1000),
nullptr};
}
PeriodicSkill::StepResult TimeoutSkill::step(const MainInput& in)
PeriodicSkill::StepResult
TimeoutSkill::step(const MainInput& in)
{
// do heavy work
std::this_thread::sleep_for(std::chrono::milliseconds(200));
......@@ -99,22 +102,22 @@ namespace armarx::skills::provider
return {ActiveOrTerminatedSkillStatus::Running, nullptr};
}
CallbackSkill::CallbackSkill() :
Skill(GetSkillDescription())
{}
CallbackSkill::CallbackSkill() : Skill(GetSkillDescription())
{
}
SkillDescription CallbackSkill::GetSkillDescription()
SkillDescription
CallbackSkill::GetSkillDescription()
{
return SkillDescription{
"ShowMeCallbacks",
"This skill does shows callbacks",
{},
armarx::core::time::Duration::MilliSeconds(1000),
nullptr
};
return SkillDescription{"ShowMeCallbacks",
"This skill does shows callbacks",
{},
armarx::core::time::Duration::MilliSeconds(1000),
nullptr};
}
Skill::MainResult CallbackSkill::main(const MainInput& in)
Skill::MainResult
CallbackSkill::main(const MainInput& in)
{
ARMARX_IMPORTANT << "Logging three updates via the callback";
auto up1 = std::make_shared<aron::data::Dict>();
......@@ -132,23 +135,26 @@ namespace armarx::skills::provider
return {TerminatedSkillStatus::Succeeded, nullptr};
}
SkillProviderExample::SkillProviderExample() : SkillProviderComponentPluginUser()
{
}
SkillProviderExample::SkillProviderExample() :
SkillProviderComponentPluginUser()
{}
armarx::PropertyDefinitionsPtr SkillProviderExample::createPropertyDefinitions()
armarx::PropertyDefinitionsPtr
SkillProviderExample::createPropertyDefinitions()
{
armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier());
armarx::PropertyDefinitionsPtr defs =
new ComponentPropertyDefinitions(getConfigIdentifier());
return defs;
}
std::string SkillProviderExample::getDefaultName() const
std::string
SkillProviderExample::getDefaultName() const
{
return "SkillProviderExample";
}
void SkillProviderExample::onInitComponent()
void
SkillProviderExample::onInitComponent()
{
// Add example skill
addSkill(std::make_unique<HelloWorldSkill>());
......@@ -160,10 +166,14 @@ namespace armarx::skills::provider
fooDesc.description = "This skill does exactly nothing.";
fooDesc.skillName = "Foo";
fooDesc.timeout = armarx::core::time::Duration::MilliSeconds(1000);
addSkill([](const std::string& clientId, const aron::data::DictPtr&){
std::cout << "Hello from Foo. The skill was called from " << clientId << "." << std::endl;
return TerminatedSkillStatus::Succeeded;
}, fooDesc);
addSkill(
[](const std::string& clientId, const aron::data::DictPtr&)
{
std::cout << "Hello from Foo. The skill was called from " << clientId << "."
<< std::endl;
return TerminatedSkillStatus::Succeeded;
},
fooDesc);
}
// Add another example skill
......@@ -176,18 +186,18 @@ namespace armarx::skills::provider
addSkill(std::make_unique<ChainingSkill>());
}
void SkillProviderExample::onConnectComponent()
void
SkillProviderExample::onConnectComponent()
{
}
void SkillProviderExample::onDisconnectComponent()
void
SkillProviderExample::onDisconnectComponent()
{
}
void SkillProviderExample::onExitComponent()
void
SkillProviderExample::onExitComponent()
{
}
}
} // namespace armarx::skills::provider
......@@ -55,16 +55,19 @@ namespace armarx
}
return qobject_cast<SimpleConfigDialog*>(dialog);
}
void
SkillManagerMonitorWidgetController::configured()
{
observerName = dialog->getProxyName("SkillManager");
}
void
SkillManagerMonitorWidgetController::loadSettings(QSettings* settings)
{
observerName = settings->value("SkillManager", "SkillManager").toString().toStdString();
}
void
SkillManagerMonitorWidgetController::saveSettings(QSettings* settings)
{
......@@ -124,10 +127,9 @@ namespace armarx
SkillManagerMonitorWidgetController::~SkillManagerMonitorWidgetController()
{
}
void
void
SkillManagerMonitorWidgetController::reconnectToSkillManager()
{
if (connected)
......@@ -136,13 +138,12 @@ namespace armarx
}
}
void
void
SkillManagerMonitorWidgetController::onInitComponent()
{
usingProxy(observerName);
}
void
SkillManagerMonitorWidgetController::onConnectComponent()
{
......@@ -479,7 +480,7 @@ namespace armarx
return;
}
auto json = aron::converter::AronNlohmannJSONConverter::ConvertToNlohmannJSON(data);
auto json = aron::data::converter::AronNlohmannJSONConverter::ConvertToNlohmannJSON(data);
QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(QString::fromStdString(json.dump(2)));
}
......@@ -490,7 +491,8 @@ namespace armarx
QClipboard* clipboard = QApplication::clipboard();
std::string s = clipboard->text().toStdString();
nlohmann::json json = nlohmann::json::parse(s);
auto data = aron::converter::AronNlohmannJSONConverter::ConvertFromNlohmannJSONObject(json);
auto data =
aron::data::converter::AronNlohmannJSONConverter::ConvertFromNlohmannJSONObject(json);
if (!aronTreeWidgetController)
{
......
......@@ -39,7 +39,6 @@
#include "../widgets/IntEnumWidget.h"
#include "../widgets/QuaternionWidget.h"
namespace armarx
{
bool
......@@ -83,7 +82,6 @@ namespace armarx
aronItem->setValueErrorState(isDirectError, false);
}
void
AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ObjectPtr& i)
{
......@@ -152,7 +150,6 @@ namespace armarx
}
}
void
AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::PairPtr& i)
{
......@@ -221,8 +218,28 @@ namespace armarx
dataSize = 8;
break;
};
// UGLY HACK: FIX ME!!!
switch (i->getElementType())
{
case armarx::aron::type::matrix::INT16:
createdMatrix->setType("short");
break;
case armarx::aron::type::matrix::INT32:
createdMatrix->setType("int");
break;
case armarx::aron::type::matrix::FLOAT32:
createdMatrix->setType("float");
break;
case armarx::aron::type::matrix::FLOAT64:
createdMatrix->setType("double");
break;
case armarx::aron::type::matrix::INT64:
createdMatrix->setType("long");
break;
};
createdMatrix->setShape({i->getRows(), i->getCols(), dataSize});
createdMatrix->setType(i->getFullName());
int totalByteSize = i->getRows() * i->getCols() * dataSize;
createdAron = createdMatrix;
......
......@@ -43,6 +43,7 @@ set(LIB_FILES
core/wm/memory_definitions.cpp
core/wm/aron_conversions.cpp
core/wm/ice_conversions.cpp
core/wm/memory_conversions.cpp
core/wm/detail/data_lookup_mixins.cpp
core/wm/visitor/Visitor.cpp
core/wm/visitor/FunctionalVisitor.cpp
......@@ -126,6 +127,7 @@ set(LIB_HEADERS
core/wm/memory_definitions.h
core/wm/aron_conversions.h
core/wm/ice_conversions.h
core/wm/memory_conversions.h
core/wm/detail/data_lookup_mixins.h
core/wm/visitor/Visitor.h
core/wm/visitor/FunctionalVisitor.h
......
......@@ -127,9 +127,11 @@ namespace armarx::armem::client
input.name = memoryID.memoryName;
ARMARX_CHECK_NOT_NULL(mns);
ARMARX_INFO << "Waiting for memory server for " << memoryID << " ...";
mns::dto::WaitForServerResult result = mns->waitForServer(input);
if (result.success)
{
ARMARX_INFO << "Resolved memory for " << memoryID << ".";
return result.server;
}
else
......
......@@ -3,14 +3,14 @@
#include <map>
#include <string>
#include <ArmarXCore/core/logging/Logging.h>
#include "ProviderSegmentBase.h"
#include "detail/AronTyped.h"
#include "detail/MemoryContainerBase.h"
#include "detail/Predictive.h"
#include "detail/iteration_mixins.h"
#include "detail/lookup_mixins.h"
#include "detail/Predictive.h"
#include <ArmarXCore/core/logging/Logging.h>
namespace armarx::armem::base
{
......@@ -20,22 +20,22 @@ namespace armarx::armem::base
*/
template <class _ProviderSegmentT, class _Derived>
class CoreSegmentBase :
public detail::MemoryContainerBase<std::map<std::string, _ProviderSegmentT>, _Derived>
, public detail::AronTyped
, public detail::PredictiveContainer<_Derived>
, public detail::ForEachEntityInstanceMixin<_Derived>
, public detail::ForEachEntitySnapshotMixin<_Derived>
, public detail::ForEachEntityMixin<_Derived>
, public detail::GetFindInstanceMixin<_Derived>
, public detail::GetFindSnapshotMixin<_Derived>
, public detail::GetFindEntityMixin<_Derived>
public detail::MemoryContainerBase<std::map<std::string, _ProviderSegmentT>, _Derived>,
public detail::AronTyped,
public detail::PredictiveContainer<_Derived>,
public detail::ForEachEntityInstanceMixin<_Derived>,
public detail::ForEachEntitySnapshotMixin<_Derived>,
public detail::ForEachEntityMixin<_Derived>,
public detail::GetFindInstanceMixin<_Derived>,
public detail::GetFindSnapshotMixin<_Derived>,
public detail::GetFindEntityMixin<_Derived>
{
using Base = detail::MemoryContainerBase<std::map<std::string, _ProviderSegmentT>, _Derived>;
using Base =
detail::MemoryContainerBase<std::map<std::string, _ProviderSegmentT>, _Derived>;
public:
using typename Base::DerivedT;
using typename Base::ContainerT;
using typename Base::DerivedT;
using ProviderSegmentT = _ProviderSegmentT;
using EntityT = typename ProviderSegmentT::EntityT;
......@@ -44,7 +44,6 @@ namespace armarx::armem::base
using ChildT = ProviderSegmentT;
struct UpdateResult
{
armarx::armem::UpdateType coreSegmentUpdateType;
......@@ -54,26 +53,29 @@ namespace armarx::armem::base
std::vector<EntitySnapshotT> removedSnapshots;
UpdateResult() = default;
UpdateResult(const typename ProviderSegmentT::UpdateResult& c) :
providerSegmentUpdateType(c.providerSegmentUpdateType),
entityUpdateType(c.entityUpdateType),
id(c.id),
removedSnapshots(c.removedSnapshots)
{}
{
}
};
public:
CoreSegmentBase()
{
}
explicit CoreSegmentBase(const std::string& name,
aron::type::ObjectPtr aronType = nullptr,
const std::vector<PredictionEngine>& predictionEngines = {}) :
CoreSegmentBase(name, MemoryID(), aronType, predictionEngines)
{
}
explicit CoreSegmentBase(const std::string& name,
const MemoryID& parentID,
aron::type::ObjectPtr aronType = nullptr,
......@@ -81,6 +83,7 @@ namespace armarx::armem::base
CoreSegmentBase(parentID.withCoreSegmentName(name), aronType, predictionEngines)
{
}
explicit CoreSegmentBase(const MemoryID& id,
aron::type::ObjectPtr aronType = nullptr,
const std::vector<PredictionEngine>& predictionEngines = {}) :
......@@ -93,71 +96,86 @@ namespace armarx::armem::base
CoreSegmentBase& operator=(const CoreSegmentBase& other) = default;
CoreSegmentBase& operator=(CoreSegmentBase&& other) = default;
// READ ACCESS
// Get key
inline std::string& name()
inline std::string&
name()
{
return this->id().coreSegmentName;
}
inline const std::string& name() const
inline const std::string&
name() const
{
return this->id().coreSegmentName;
}
// Has child by key
bool hasProviderSegment(const std::string& name) const
bool
hasProviderSegment(const std::string& name) const
{
return this->findProviderSegment(name) != nullptr;
}
// Has child by memory ID
bool hasProviderSegment(const MemoryID& providerSegmentID) const
bool
hasProviderSegment(const MemoryID& providerSegmentID) const
{
return this->findProviderSegment(providerSegmentID) != nullptr;
}
// Find child by key
ProviderSegmentT* findProviderSegment(const std::string& name)
ProviderSegmentT*
findProviderSegment(const std::string& name)
{
return detail::findChildByKey(name, this->_container);
}
const ProviderSegmentT* findProviderSegment(const std::string& name) const
const ProviderSegmentT*
findProviderSegment(const std::string& name) const
{
return detail::findChildByKey(name, this->_container);
}
// Get child by key
ProviderSegmentT& getProviderSegment(const std::string& name)
ProviderSegmentT&
getProviderSegment(const std::string& name)
{
return detail::getChildByKey(name, this->_container, *this);
}
const ProviderSegmentT& getProviderSegment(const std::string& name) const
const ProviderSegmentT&
getProviderSegment(const std::string& name) const
{
return detail::getChildByKey(name, this->_container, *this);
}
// Find child by MemoryID
ProviderSegmentT* findProviderSegment(const MemoryID& providerSegmentID)
ProviderSegmentT*
findProviderSegment(const MemoryID& providerSegmentID)
{
detail::checkHasProviderSegmentName(providerSegmentID);
return this->findProviderSegment(providerSegmentID.providerSegmentName);
}
const ProviderSegmentT* findProviderSegment(const MemoryID& providerSegmentID) const
const ProviderSegmentT*
findProviderSegment(const MemoryID& providerSegmentID) const
{
detail::checkHasProviderSegmentName(providerSegmentID);
return this->findProviderSegment(providerSegmentID.providerSegmentName);
}
// Get child by MemoryID
ProviderSegmentT& getProviderSegment(const MemoryID& providerSegmentID)
ProviderSegmentT&
getProviderSegment(const MemoryID& providerSegmentID)
{
detail::checkHasProviderSegmentName(providerSegmentID);
return this->getProviderSegment(providerSegmentID.providerSegmentName);
}
const ProviderSegmentT& getProviderSegment(const MemoryID& providerSegmentID) const
const ProviderSegmentT&
getProviderSegment(const MemoryID& providerSegmentID) const
{
detail::checkHasProviderSegmentName(providerSegmentID);
return this->getProviderSegment(providerSegmentID.providerSegmentName);
......@@ -171,35 +189,42 @@ namespace armarx::armem::base
// Search all provider segments for the first matching entity.
bool hasEntity(const std::string& entityName) const
bool
hasEntity(const std::string& entityName) const
{
return this->findEntity(entityName) != nullptr;
}
EntityT* findEntity(const std::string& entityName)
EntityT*
findEntity(const std::string& entityName)
{
return _findEntity(*this, entityName);
}
const EntityT* findEntity(const std::string& entityName) const
const EntityT*
findEntity(const std::string& entityName) const
{
return _findEntity(*this, entityName);
}
// ITERATION
/**
* @param func Function like: bool process(ProviderSegmentT& provSeg)
*/
template <class ProviderSegmentFunctionT>
bool forEachProviderSegment(ProviderSegmentFunctionT&& func)
bool
forEachProviderSegment(ProviderSegmentFunctionT&& func)
{
return this->forEachChild(func);
}
/**
* @param func Function like: bool process(const ProviderSegmentT& provSeg)
*/
template <class ProviderSegmentFunctionT>
bool forEachProviderSegment(ProviderSegmentFunctionT&& func) const
bool
forEachProviderSegment(ProviderSegmentFunctionT&& func) const
{
return this->forEachChild(func);
}
......@@ -213,33 +238,41 @@ namespace armarx::armem::base
* @param func Function like void process(EntityInstanceT& instance)>
*/
template <class InstanceFunctionT>
bool forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func)
bool
forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func)
{
return detail::forEachInstanceIn(
id, func, *this,
id.hasProviderSegmentName(),
id.hasProviderSegmentName() ? this->findProviderSegment(id.providerSegmentName) : nullptr);
return detail::forEachInstanceIn(id,
func,
*this,
id.hasProviderSegmentName(),
id.hasProviderSegmentName()
? this->findProviderSegment(id.providerSegmentName)
: nullptr);
}
/**
* @param func Function like void process(EntityInstanceT& instance)>
*/
template <class InstanceFunctionT>
bool forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func) const
bool
forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func) const
{
return detail::forEachInstanceIn(
id, func, *this,
id.hasProviderSegmentName(),
id.hasProviderSegmentName() ? this->findProviderSegment(id.providerSegmentName) : nullptr);
return detail::forEachInstanceIn(id,
func,
*this,
id.hasProviderSegmentName(),
id.hasProviderSegmentName()
? this->findProviderSegment(id.providerSegmentName)
: nullptr);
}
// Get child keys
std::vector<std::string> getProviderSegmentNames() const
std::vector<std::string>
getProviderSegmentNames() const
{
return simox::alg::get_keys(this->_container);
}
// MODIFICATION
/**
......@@ -247,11 +280,13 @@ namespace armarx::armem::base
*
* Missing entity entries are added before updating.
*/
UpdateResult update(const EntityUpdate& update)
UpdateResult
update(const EntityUpdate& update)
{
this->_checkContainerName(update.entityID.coreSegmentName, this->name());
auto [inserted, provSeg] = _addProviderSegmentIfMissing(update.entityID.providerSegmentName);
auto [inserted, provSeg] =
_addProviderSegmentIfMissing(update.entityID.providerSegmentName);
// Update entry.
......@@ -267,20 +302,34 @@ namespace armarx::armem::base
return ret;
}
template <class OtherDerivedT>
void append(const OtherDerivedT& other)
void
append(const OtherDerivedT& other)
{
other.forEachProviderSegment([this](const auto& provSeg)
{
auto it = this->_container.find(provSeg.name());
if (it == this->_container.end())
other.forEachProviderSegment(
[this](const auto& provSeg)
{
it = this->_container.emplace(provSeg.name(), this->id().withProviderSegmentName(provSeg.name())).first;
}
it->second.append(provSeg);
return true;
});
auto it = this->_container.find(provSeg.name());
if (it == this->_container.end())
{
it = this->_container
.emplace(provSeg.name(),
this->id().withProviderSegmentName(provSeg.name()))
.first;
it->second.aronType() = provSeg.aronType();
}
/*TODO: if (it->second.aronType() != provSeg.aronType())
{
ARMARX_WARNING
<< "When appending a coreseg to another coreseg type conflicts have "
"been found. Setting the type to NULL...";
it->second.aronType() = nullptr;
}*/
it->second.append(provSeg);
return true;
});
}
/**
......@@ -296,36 +345,41 @@ namespace armarx::armem::base
aron::type::ObjectPtr providerSegmentType = nullptr,
const std::vector<PredictionEngine>& predictionEngines = {})
{
aron::type::ObjectPtr type = providerSegmentType ? providerSegmentType : this->aronType();
aron::type::ObjectPtr type =
providerSegmentType ? providerSegmentType : this->aronType();
return this->_derived().addProviderSegment(name, name, type, predictionEngines);
}
/// Copy and insert a provider segment.
ProviderSegmentT& addProviderSegment(const ProviderSegmentT& providerSegment)
ProviderSegmentT&
addProviderSegment(const ProviderSegmentT& providerSegment)
{
return this->_derived().addProviderSegment(providerSegment.name(), ProviderSegmentT(providerSegment));
return this->_derived().addProviderSegment(providerSegment.name(),
ProviderSegmentT(providerSegment));
}
/// Move and insert a provider segment.
ProviderSegmentT& addProviderSegment(ProviderSegmentT&& providerSegment)
ProviderSegmentT&
addProviderSegment(ProviderSegmentT&& providerSegment)
{
const std::string name = providerSegment.name(); // Copy before move.
const std::string name = providerSegment.name(); // Copy before move.
return this->_derived().addProviderSegment(name, std::move(providerSegment));
}
/// Insert a provider segment in-place.
template <class ...Args>
ProviderSegmentT& addProviderSegment(const std::string& name, Args... args)
template <class... Args>
ProviderSegmentT&
addProviderSegment(const std::string& name, Args... args)
{
ChildT& child = this->template _addChild<ChildT>(name, args...);
child.id() = this->id().withProviderSegmentName(name);
return child;
}
// MISC
bool equalsDeep(const DerivedT& other) const
bool
equalsDeep(const DerivedT& other) const
{
//std::cout << "CoreSegment::equalsDeep" << std::endl;
if (this->size() != other.size())
......@@ -346,34 +400,34 @@ namespace armarx::armem::base
return true;
}
static std::string getLevelName()
static std::string
getLevelName()
{
return "core segment";
}
std::string getKeyString() const
std::string
getKeyString() const
{
return this->name();
}
protected:
template <class ParentT>
static
auto*
static auto*
_findEntity(ParentT&& parent, const std::string& entityName)
{
decltype(parent.findEntity(entityName)) result = nullptr;
parent.forEachProviderSegment([&result, &entityName](auto & provSeg)
{
result = provSeg.findEntity(entityName);
return result == nullptr; // Keep going if null, break if not null.
});
parent.forEachProviderSegment(
[&result, &entityName](auto& provSeg)
{
result = provSeg.findEntity(entityName);
return result == nullptr; // Keep going if null, break if not null.
});
return result;
}
std::pair<bool, ProviderSegmentT*>
_addProviderSegmentIfMissing(const std::string& providerSegmentName)
{
......@@ -402,9 +456,7 @@ namespace armarx::armem::base
private:
bool _addMissingProviderSegmentDuringUpdate = true;
};
}
} // namespace armarx::armem::base
......@@ -132,6 +132,16 @@ namespace armarx::armem::base
return _data;
}
void setData(DataT& d)
{
_data = d;
}
void setMetadata(MetadataT& m)
{
_metadata = m;
}
/**
* @brief Get the data converted to a generated Aron DTO class.
*/
......
......@@ -5,10 +5,9 @@
#include "CoreSegmentBase.h"
#include "detail/MemoryContainerBase.h"
#include "detail/Predictive.h"
#include "detail/iteration_mixins.h"
#include "detail/lookup_mixins.h"
#include "detail/Predictive.h"
namespace armarx::armem::base
{
......@@ -18,23 +17,22 @@ namespace armarx::armem::base
*/
template <class _CoreSegmentT, class _Derived>
class MemoryBase :
public detail::MemoryContainerBase<std::map<std::string, _CoreSegmentT>, _Derived>
, public detail::PredictiveContainer<_Derived>
, public detail::ForEachEntityInstanceMixin<_Derived>
, public detail::ForEachEntitySnapshotMixin<_Derived>
, public detail::ForEachEntityMixin<_Derived>
, public detail::ForEachProviderSegmentMixin<_Derived>
, public detail::GetFindInstanceMixin<_Derived>
, public detail::GetFindSnapshotMixin<_Derived>
, public detail::GetFindEntityMixin<_Derived>
, public detail::GetFindProviderSegmentMixin<_Derived>
public detail::MemoryContainerBase<std::map<std::string, _CoreSegmentT>, _Derived>,
public detail::PredictiveContainer<_Derived>,
public detail::ForEachEntityInstanceMixin<_Derived>,
public detail::ForEachEntitySnapshotMixin<_Derived>,
public detail::ForEachEntityMixin<_Derived>,
public detail::ForEachProviderSegmentMixin<_Derived>,
public detail::GetFindInstanceMixin<_Derived>,
public detail::GetFindSnapshotMixin<_Derived>,
public detail::GetFindEntityMixin<_Derived>,
public detail::GetFindProviderSegmentMixin<_Derived>
{
using Base = detail::MemoryContainerBase<std::map<std::string, _CoreSegmentT>, _Derived>;
public:
using typename Base::DerivedT;
using typename Base::ContainerT;
using typename Base::DerivedT;
using CoreSegmentT = _CoreSegmentT;
using ProviderSegmentT = typename CoreSegmentT::ProviderSegmentT;
......@@ -44,7 +42,6 @@ namespace armarx::armem::base
using ChildT = CoreSegmentT;
struct UpdateResult
{
armarx::armem::UpdateType memoryUpdateType;
......@@ -55,25 +52,28 @@ namespace armarx::armem::base
std::vector<EntitySnapshotT> removedSnapshots;
UpdateResult() = default;
UpdateResult(const typename CoreSegmentT::UpdateResult& c) :
coreSegmentUpdateType(c.coreSegmentUpdateType),
providerSegmentUpdateType(c.providerSegmentUpdateType),
entityUpdateType(c.entityUpdateType),
id(c.id),
removedSnapshots(c.removedSnapshots)
{}
{
}
};
public:
MemoryBase()
{
}
explicit MemoryBase(const std::string& name,
const std::vector<PredictionEngine>& predictionEngines = {}) :
MemoryBase(MemoryID().withMemoryName(name), predictionEngines)
{
}
explicit MemoryBase(const MemoryID& id,
const std::vector<PredictionEngine>& predictionEngines = {}) :
Base(id), detail::PredictiveContainer<_Derived>(predictionEngines)
......@@ -85,70 +85,86 @@ namespace armarx::armem::base
MemoryBase& operator=(const MemoryBase& other) = default;
MemoryBase& operator=(MemoryBase&& other) = default;
// READ ACCESS
// Get key
inline std::string& name()
inline std::string&
name()
{
return this->id().memoryName;
}
inline const std::string& name() const
inline const std::string&
name() const
{
return this->id().memoryName;
}
// Has child by key
bool hasCoreSegment(const std::string& name) const
bool
hasCoreSegment(const std::string& name) const
{
return this->findCoreSegment(name) != nullptr;
}
// Has child by MemoryID
bool hasCoreSegment(const MemoryID& coreSegmentID) const
bool
hasCoreSegment(const MemoryID& coreSegmentID) const
{
return this->findCoreSegment(coreSegmentID) != nullptr;
}
// Find child by key
CoreSegmentT* findCoreSegment(const std::string& name)
CoreSegmentT*
findCoreSegment(const std::string& name)
{
return detail::findChildByKey(name, this->_container);
}
const CoreSegmentT* findCoreSegment(const std::string& name) const
const CoreSegmentT*
findCoreSegment(const std::string& name) const
{
return detail::findChildByKey(name, this->_container);
}
// Get child by key
CoreSegmentT& getCoreSegment(const std::string& name)
CoreSegmentT&
getCoreSegment(const std::string& name)
{
return detail::getChildByKey(name, this->_container, *this);
}
const CoreSegmentT& getCoreSegment(const std::string& name) const
const CoreSegmentT&
getCoreSegment(const std::string& name) const
{
return detail::getChildByKey(name, this->_container, *this);
}
// Find child by MemoryID
CoreSegmentT* findCoreSegment(const MemoryID& coreSegmentID)
CoreSegmentT*
findCoreSegment(const MemoryID& coreSegmentID)
{
detail::checkHasCoreSegmentName(coreSegmentID);
return this->findCoreSegment(coreSegmentID.coreSegmentName);
}
const CoreSegmentT* findCoreSegment(const MemoryID& coreSegmentID) const
const CoreSegmentT*
findCoreSegment(const MemoryID& coreSegmentID) const
{
detail::checkHasCoreSegmentName(coreSegmentID);
return this->findCoreSegment(coreSegmentID.coreSegmentName);
}
// Get child by MemoryID
CoreSegmentT& getCoreSegment(const MemoryID& coreSegmentID)
CoreSegmentT&
getCoreSegment(const MemoryID& coreSegmentID)
{
detail::checkHasCoreSegmentName(coreSegmentID);
return this->getCoreSegment(coreSegmentID.coreSegmentName);
}
const CoreSegmentT& getCoreSegment(const MemoryID& coreSegmentID) const
const CoreSegmentT&
getCoreSegment(const MemoryID& coreSegmentID) const
{
detail::checkHasCoreSegmentName(coreSegmentID);
return this->getCoreSegment(coreSegmentID.coreSegmentName);
......@@ -160,22 +176,24 @@ namespace armarx::armem::base
// get/findProviderSegment are provided by GetFindProviderSegmentMixin
// ITERATION
/**
* @param func Function like: bool process(CoreSegmentT& coreSeg)
*/
template <class CoreSegmentFunctionT>
bool forEachCoreSegment(CoreSegmentFunctionT&& func)
bool
forEachCoreSegment(CoreSegmentFunctionT&& func)
{
return this->forEachChild(func);
}
/**
* @param func Function like: bool process(const CoreSegmentT& coreSeg)
*/
template <class CoreSegmentFunctionT>
bool forEachCoreSegment(CoreSegmentFunctionT&& func) const
bool
forEachCoreSegment(CoreSegmentFunctionT&& func) const
{
return this->forEachChild(func);
}
......@@ -190,34 +208,46 @@ namespace armarx::armem::base
* @param func Function like void process(EntityInstanceT& instance)>
*/
template <class InstanceFunctionT>
bool forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func)
bool
forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func)
{
return detail::forEachInstanceIn(
id, func, *this,
id.hasCoreSegmentName(),
id.hasCoreSegmentName() ? this->findCoreSegment(id.coreSegmentName) : nullptr);
id,
func,
*this,
id.hasCoreSegmentName(),
id.hasCoreSegmentName() ? this->findCoreSegment(id.coreSegmentName) : nullptr);
}
/**
* @param func Function like void process(EntityInstanceT& instance)>
*/
template <class InstanceFunctionT>
bool forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func) const
bool
forEachInstanceIn(const MemoryID& id, InstanceFunctionT&& func) const
{
return detail::forEachInstanceIn(
id, func, *this,
id.hasCoreSegmentName(),
id.hasCoreSegmentName() ? this->findCoreSegment(id.coreSegmentName) : nullptr);
id,
func,
*this,
id.hasCoreSegmentName(),
id.hasCoreSegmentName() ? this->findCoreSegment(id.coreSegmentName) : nullptr);
}
std::vector<std::string> getCoreSegmentNames() const
std::vector<std::string>
getCoreSegmentNames() const
{
return simox::alg::get_keys(this->_container);
}
// MODIFICATION
void
setName(const std::string& name)
{
this->id().memoryName = name;
}
/**
* @brief Add an empty core segment with the given name, type and prediction engines.
* @param name The core segment name.
......@@ -234,39 +264,45 @@ namespace armarx::armem::base
}
/// Copy and insert a core segment.
CoreSegmentT& addCoreSegment(const CoreSegmentT& coreSegment)
CoreSegmentT&
addCoreSegment(const CoreSegmentT& coreSegment)
{
return this->_derived().addCoreSegment(coreSegment.name(), CoreSegmentT(coreSegment));
}
/// Move and insert a core segment.
CoreSegmentT& addCoreSegment(CoreSegmentT&& coreSegment)
CoreSegmentT&
addCoreSegment(CoreSegmentT&& coreSegment)
{
const std::string name = coreSegment.name(); // Copy before move.
const std::string name = coreSegment.name(); // Copy before move.
return this->_derived().addCoreSegment(name, std::move(coreSegment));
}
/// Move and insert a core segment.
template <class ...Args>
CoreSegmentT& addCoreSegment(const std::string& name, Args... args)
template <class... Args>
CoreSegmentT&
addCoreSegment(const std::string& name, Args... args)
{
CoreSegmentT& child = this->template _addChild<ChildT>(name, args...);
child.id() = this->id().withCoreSegmentName(name);
return child;
}
/**
* @brief Store all updates in `commit`.
* @param commit The commit.
* @return The resulting memory IDs.
*/
std::vector<UpdateResult> update(const Commit& commit, const bool addMissingCoreSegmentDuringUpdate = false, const bool checkMemoryName = true)
std::vector<UpdateResult>
update(const Commit& commit,
const bool addMissingCoreSegmentDuringUpdate = false,
const bool checkMemoryName = true)
{
std::vector<UpdateResult> results;
for (const EntityUpdate& update : commit.updates)
{
results.push_back(this->update(update, addMissingCoreSegmentDuringUpdate, checkMemoryName));
results.push_back(
this->update(update, addMissingCoreSegmentDuringUpdate, checkMemoryName));
}
return results;
}
......@@ -276,14 +312,18 @@ namespace armarx::armem::base
* @param update The update.
* @return The resulting entity snapshot's ID.
*/
UpdateResult update(const EntityUpdate& update, const bool addMissingCoreSegmentDuringUpdate = false, const bool checkMemoryName = true)
UpdateResult
update(const EntityUpdate& update,
const bool addMissingCoreSegmentDuringUpdate = false,
const bool checkMemoryName = true)
{
if (checkMemoryName)
{
this->_checkContainerName(update.entityID.memoryName, this->name());
}
auto [inserted, coreSeg] = _addCoreSegmentIfMissing(update.entityID.coreSegmentName, addMissingCoreSegmentDuringUpdate);
auto [inserted, coreSeg] = _addCoreSegmentIfMissing(update.entityID.coreSegmentName,
addMissingCoreSegmentDuringUpdate);
// Update entry.
UpdateResult ret(coreSeg->update(update));
......@@ -298,27 +338,42 @@ namespace armarx::armem::base
return ret;
}
/**
* @brief Merge another memory into this one. Append all data
* @brief Merge another memory into this one. Append all data and types if possible
* @param m The other memory
*/
template <class OtherDerivedT>
void append(const OtherDerivedT& other)
void
append(const OtherDerivedT& other)
{
other.forEachCoreSegment([this](const auto& coreSeg)
{
auto it = this->_container.find(coreSeg.name());
if (it == this->_container.end())
other.forEachCoreSegment(
[this](const auto& coreSeg)
{
it = this->_container.emplace(coreSeg.name(), this->id().withCoreSegmentName(coreSeg.name())).first;
}
it->second.append(coreSeg);
return true;
});
auto it = this->_container.find(coreSeg.name());
if (it == this->_container.end())
{
it = this->_container
.emplace(coreSeg.name(),
this->id().withCoreSegmentName(coreSeg.name()))
.first;
it->second.aronType() = coreSeg.aronType();
}
/*TODO: if (it->second.aronType() != coreSeg.aronType())
{
ARMARX_WARNING << "When appending a wm to another wm type conflicts have "
"been found. Setting the type to NULL...";
it->second.aronType() = nullptr;
}*/
it->second.append(coreSeg);
return true;
});
}
bool equalsDeep(const MemoryBase& other) const
bool
equalsDeep(const MemoryBase& other) const
{
//std::cout << "Memory::equalsDeep" << std::endl;
if (this->size() != other.size())
......@@ -339,20 +394,23 @@ namespace armarx::armem::base
return true;
}
static std::string getLevelName()
static std::string
getLevelName()
{
return "memory";
}
std::string getKeyString() const
std::string
getKeyString() const
{
return this->name();
}
protected:
std::pair<bool, CoreSegmentT*> _addCoreSegmentIfMissing(const std::string& coreSegmentName, const bool addMissingCoreSegmentDuringUpdate)
std::pair<bool, CoreSegmentT*>
_addCoreSegmentIfMissing(const std::string& coreSegmentName,
const bool addMissingCoreSegmentDuringUpdate)
{
CoreSegmentT* coreSeg = nullptr;
......@@ -377,4 +435,4 @@ namespace armarx::armem::base
}
}
};
}
} // namespace armarx::armem::base
#pragma once
#include "derived.h"
#include <RobotAPI/libraries/armem/core/MemoryID.h>
#include <RobotAPI/libraries/armem/core/error/ArMemError.h>
#include "derived.h"
namespace armarx::armem::base::detail
{
......@@ -16,9 +15,9 @@ namespace armarx::armem::base::detail
void checkHasCoreSegmentName(const MemoryID& coreSegmentID);
void checkHasMemoryName(const MemoryID& memory);
template <class KeyT, class ContainerT>
auto* findChildByKey(const KeyT& key, ContainerT&& container)
auto*
findChildByKey(const KeyT& key, ContainerT&& container)
{
auto it = container.find(key);
return it != container.end() ? &it->second : nullptr;
......@@ -26,11 +25,10 @@ namespace armarx::armem::base::detail
template <class KeyT, class ContainerT, class ParentT, class KeyStringFn>
auto&
getChildByKey(
const KeyT& key,
ContainerT&& container,
const ParentT& parent,
KeyStringFn&& keyStringFn)
getChildByKey(const KeyT& key,
ContainerT&& container,
const ParentT& parent,
KeyStringFn&& keyStringFn)
{
if (auto* child = findChildByKey(key, container))
{
......@@ -38,29 +36,25 @@ namespace armarx::armem::base::detail
}
else
{
throw armem::error::MissingEntry::create<typename ParentT::ChildT>(keyStringFn(key), parent);
throw armem::error::MissingEntry::create<typename ParentT::ChildT>(keyStringFn(key),
parent);
}
}
template <class KeyT, class ContainerT, class ParentT>
auto&
getChildByKey(
const KeyT& key,
ContainerT&& container,
const ParentT& parent)
getChildByKey(const KeyT& key, ContainerT&& container, const ParentT& parent)
{
return getChildByKey(key, container, parent, [](const KeyT & key)
{
return key;
});
return getChildByKey(key, container, parent, [](const KeyT& key) { return key; });
}
template <class DerivedT>
struct GetFindInstanceMixin
{
// Relies on this->find/getSnapshot()
bool hasInstance(const MemoryID& instanceID) const
bool
hasInstance(const MemoryID& instanceID) const
{
return derived<DerivedT>(this).findInstance(instanceID) != nullptr;
}
......@@ -76,6 +70,7 @@ namespace armarx::armem::base::detail
auto* snapshot = derived<DerivedT>(this).findSnapshot(instanceID);
return snapshot ? snapshot->findInstance(instanceID) : nullptr;
}
const auto*
findInstance(const MemoryID& instanceID) const
{
......@@ -94,6 +89,7 @@ namespace armarx::armem::base::detail
{
return derived<DerivedT>(this).getSnapshot(instanceID).getInstance(instanceID);
}
const auto&
getInstance(const MemoryID& instanceID) const
{
......@@ -101,13 +97,13 @@ namespace armarx::armem::base::detail
}
};
template <class DerivedT>
struct GetFindSnapshotMixin
{
// Relies on this->find/getEntity()
bool hasSnapshot(const MemoryID& snapshotID) const
bool
hasSnapshot(const MemoryID& snapshotID) const
{
return derived<DerivedT>(this).findSnapshot(snapshotID) != nullptr;
}
......@@ -123,6 +119,7 @@ namespace armarx::armem::base::detail
auto* entity = derived<DerivedT>(this).findEntity(snapshotID);
return entity ? entity->findSnapshot(snapshotID) : nullptr;
}
const auto*
findSnapshot(const MemoryID& snapshotID) const
{
......@@ -141,47 +138,51 @@ namespace armarx::armem::base::detail
{
return derived<DerivedT>(this).getEntity(snapshotID).getSnapshot(snapshotID);
}
const auto&
getSnapshot(const MemoryID& snapshotID) const
{
return derived<DerivedT>(this).getEntity(snapshotID).getSnapshot(snapshotID);
}
// More elaborate cases
auto* findLatestSnapshot(const MemoryID& entityID)
auto*
findLatestSnapshot(const MemoryID& entityID)
{
auto* entity = derived<DerivedT>(this).findEntity(entityID);
return entity ? entity->findLatestSnapshot() : nullptr;
}
const auto* findLatestSnapshot(const MemoryID& entityID) const
const auto*
findLatestSnapshot(const MemoryID& entityID) const
{
auto* entity = derived<DerivedT>(this).findEntity(entityID);
return entity ? entity->findLatestSnapshot() : nullptr;
}
auto* findLatestInstance(const MemoryID& entityID, int instanceIndex = 0)
auto*
findLatestInstance(const MemoryID& entityID, int instanceIndex = 0)
{
auto* snapshot = derived<DerivedT>(this).findLatestSnapshot(entityID);
return snapshot ? snapshot->findInstance(instanceIndex) : nullptr;
}
const auto* findLatestInstance(const MemoryID& entityID, int instanceIndex = 0) const
const auto*
findLatestInstance(const MemoryID& entityID, int instanceIndex = 0) const
{
auto* snapshot = derived<DerivedT>(this).findLatestSnapshot(entityID);
return snapshot ? snapshot->findInstance(instanceIndex) : nullptr;
}
};
template <class DerivedT>
struct GetFindEntityMixin
{
// Relies on this->find/getProviderSegment()
bool hasEntity(const MemoryID& entityID) const
bool
hasEntity(const MemoryID& entityID) const
{
return derived<DerivedT>(this).findEntity(entityID) != nullptr;
}
......@@ -197,6 +198,7 @@ namespace armarx::armem::base::detail
auto* provSeg = derived<DerivedT>(this).findProviderSegment(entityID);
return provSeg ? provSeg->findEntity(entityID) : nullptr;
}
const auto*
findEntity(const MemoryID& entityID) const
{
......@@ -215,6 +217,7 @@ namespace armarx::armem::base::detail
{
return derived<DerivedT>(this).getProviderSegment(entityID).getEntity(entityID);
}
const auto&
getEntity(const MemoryID& entityID) const
{
......@@ -222,14 +225,13 @@ namespace armarx::armem::base::detail
}
};
template <class DerivedT>
struct GetFindProviderSegmentMixin
{
// Relies on this->find/getCoreSegment()
bool hasProviderSegment(const MemoryID& providerSegmentID) const
bool
hasProviderSegment(const MemoryID& providerSegmentID) const
{
return derived<DerivedT>(this).findProviderSegment(providerSegmentID) != nullptr;
}
......@@ -245,6 +247,7 @@ namespace armarx::armem::base::detail
auto* provSeg = derived<DerivedT>(this).findCoreSegment(providerSegmentID);
return provSeg ? provSeg->findProviderSegment(providerSegmentID) : nullptr;
}
const auto*
findProviderSegment(const MemoryID& providerSegmentID) const
{
......@@ -261,14 +264,18 @@ namespace armarx::armem::base::detail
auto&
getProviderSegment(const MemoryID& providerSegmentID)
{
return derived<DerivedT>(this).getCoreSegment(providerSegmentID).getProviderSegment(providerSegmentID);
return derived<DerivedT>(this)
.getCoreSegment(providerSegmentID)
.getProviderSegment(providerSegmentID);
}
const auto&
getProviderSegment(const MemoryID& providerSegmentID) const
{
return derived<DerivedT>(this).getCoreSegment(providerSegmentID).getProviderSegment(providerSegmentID);
return derived<DerivedT>(this)
.getCoreSegment(providerSegmentID)
.getProviderSegment(providerSegmentID);
}
};
}
} // namespace armarx::armem::base::detail
#include "memory_conversions.h"
namespace armarx::armem::wm
{
void
toMemory(Memory& m, const std::vector<CoreSegment>& e)
{
m.clear();
for (const auto& s : e)
{
m.addCoreSegment(s);
}
}
void
toMemory(Memory& m, const std::vector<ProviderSegment>& e)
{
m.clear();
for (const auto& s : e)
{
if (!m.hasCoreSegment(s.id().coreSegmentName))
{
m.addCoreSegment(s.id().coreSegmentName);
}
auto* c = m.findCoreSegment(s.id().coreSegmentName);
c->addProviderSegment(s);
}
}
void
toMemory(Memory& m, const std::vector<Entity>& e)
{
m.clear();
for (const auto& s : e)
{
if (!m.hasCoreSegment(s.id().coreSegmentName))
{
m.addCoreSegment(s.id().coreSegmentName);
}
auto* c = m.findCoreSegment(s.id().coreSegmentName);
if (!c->hasProviderSegment(s.id().providerSegmentName))
{
c->addProviderSegment(s.id().providerSegmentName);
}
auto* p = c->findProviderSegment(s.id().providerSegmentName);
p->addEntity(s);
}
}
void
toMemory(Memory& m, const std::vector<EntitySnapshot>& e)
{
m.clear();
for (const auto& s : e)
{
if (!m.hasCoreSegment(s.id().coreSegmentName))
{
m.addCoreSegment(s.id().coreSegmentName);
}
auto* c = m.findCoreSegment(s.id().coreSegmentName);
if (!c->hasProviderSegment(s.id().providerSegmentName))
{
c->addProviderSegment(s.id().providerSegmentName);
}
auto* p = c->findProviderSegment(s.id().providerSegmentName);
if (!p->hasEntity(s.id().entityName))
{
p->addEntity(s.id().entityName);
}
auto* en = p->findEntity(s.id().entityName);
en->addSnapshot(s);
}
}
void
toMemory(Memory& m, const std::vector<EntityInstance>& e)
{
m.clear();
for (const auto& s : e)
{
if (!m.hasCoreSegment(s.id().coreSegmentName))
{
m.addCoreSegment(s.id().coreSegmentName);
}
auto* c = m.findCoreSegment(s.id().coreSegmentName);
if (!c->hasProviderSegment(s.id().providerSegmentName))
{
c->addProviderSegment(s.id().providerSegmentName);
}
auto* p = c->findProviderSegment(s.id().providerSegmentName);
if (!p->hasEntity(s.id().entityName))
{
p->addEntity(s.id().entityName);
}
auto* en = p->findEntity(s.id().entityName);
if (!en->hasSnapshot(s.id().timestamp))
{
en->addSnapshot(s.id().timestamp);
}
auto* sn = p->findSnapshot(s.id());
sn->addInstance(s);
}
}
} // namespace armarx::armem::wm
#pragma once
#include <vector>
#include "memory_definitions.h"
namespace armarx::armem::wm
{
void toMemory(Memory& m, const std::vector<CoreSegment>& e);
void toMemory(Memory& m, const std::vector<ProviderSegment>& e);
void toMemory(Memory& m, const std::vector<Entity>& e);
void toMemory(Memory& m, const std::vector<EntitySnapshot>& e);
void toMemory(Memory& m, const std::vector<EntityInstance>& e);
} // namespace armarx::armem::wm
......@@ -7,18 +7,9 @@ SET(INSTALL_SCRIPT_MSG
"Please use the installation script in RobotAPI/etc/mongocxx to install libmongocxx and libbsoncxx."
)
# MongoLTM
#find_package(libmongocxx QUIET)
#armarx_build_if(libmongocxx_FOUND "libmongocxx not available. ${INSTALL_SCRIPT_MSG}")
# DiskLTM TODO: switch to FindMinizip file?
INCLUDE (FindPkgConfig)
if (PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(UNZIP minizip)
endif (PKG_CONFIG_FOUND)
armarx_build_if(UNZIP_FOUND "MiniZip not available.")
find_package(libmongocxx QUIET)
armarx_build_if(libmongocxx_FOUND "libmongocxx not available. ${INSTALL_SCRIPT_MSG}")
# LTM Encoding stuff
find_package(libbsoncxx QUIET)
......@@ -35,9 +26,8 @@ set(LIBS
# LTM
RobotAPI::aron::converter::json
RobotAPI::aron::converter::opencv
#${LIBMONGOCXX_LIBRARIES}
${LIBMONGOCXX_LIBRARIES}
${LIBBSONCXX_LIBRARIES}
${UNZIP_LIBRARIES}
)
set(LIB_FILES
......@@ -45,50 +35,57 @@ set(LIB_FILES
MemoryRemoteGui.cpp
RemoteGuiAronDataVisitor.cpp
# LTM
ltm/io/Recording.cpp
ltm/io/Replaying.cpp
ltm/base/detail/Processors.cpp
ltm/base/detail/MemoryItem.cpp
ltm/base/detail/MemoryBase.cpp
ltm/base/detail/BufferedMemoryBase.cpp
ltm/base/detail/LUTMemoryBase.cpp
ltm/base/detail/CoreSegmentBase.cpp
ltm/base/detail/ProviderSegmentBase.cpp
ltm/base/detail/EntityBase.cpp
ltm/base/detail/EntitySnapshotBase.cpp
ltm/base/filter/Filter.cpp
ltm/base/filter/frequencyFilter/FrequencyFilter.cpp
ltm/base/filter/equalityFilter/EqualityFilter.cpp
ltm/base/extractor/Extractor.cpp
ltm/base/extractor/imageExtractor/ImageExtractor.cpp
ltm/base/extractor/imageExtractor/DepthImageExtractor.cpp
ltm/base/converter/Converter.cpp
ltm/base/typeConverter/Converter.cpp
ltm/base/typeConverter/json/JsonConverter.cpp
ltm/base/converter/object/Converter.cpp
ltm/base/converter/object/json/JsonConverter.cpp
ltm/base/converter/object/bson/BsonConverter.cpp
ltm/base/converter/image/Converter.cpp
ltm/base/converter/image/png/PngConverter.cpp
ltm/base/converter/image/exr/ExrConverter.cpp
ltm/base/forgetter/Forgetter.cpp
ltm/base/forgetter/LRUForgetter/LRUForgetter.cpp
ltm/disk/detail/util/util.cpp
ltm/disk/detail/util/filesystem_util.cpp
ltm/disk/detail/util/minizip_util.cpp
ltm/disk/detail/DiskStorage.cpp
ltm/disk/Memory.cpp
ltm/disk/CoreSegment.cpp
ltm/disk/ProviderSegment.cpp
ltm/disk/Entity.cpp
ltm/disk/EntitySnapshot.cpp
ltm/detail/mixins/util/filesystem.cpp
ltm/detail/mixins/util/mongodb.cpp
ltm/detail/mixins/CachedMemoryMixin.cpp
ltm/detail/mixins/BufferedMemoryMixin.cpp
ltm/detail/mixins/DiskStorageMixin.cpp
ltm/detail/mixins/MongoDBStorageMixin.cpp
ltm/detail/MemoryItem.cpp
ltm/detail/MemoryBase.cpp
ltm/detail/CoreSegmentBase.cpp
ltm/detail/ProviderSegmentBase.cpp
ltm/detail/EntityBase.cpp
ltm/detail/EntitySnapshotBase.cpp
ltm/detail/EntityInstanceBase.cpp
ltm/processors/Processors.cpp
ltm/processors/filter/Filter.cpp
ltm/processors/filter/frequencyFilter/FrequencyFilter.cpp
ltm/processors/filter/equalityFilter/EqualityFilter.cpp
ltm/processors/extractor/Extractor.cpp
ltm/processors/extractor/imageExtractor/ImageExtractor.cpp
ltm/processors/extractor/imageExtractor/DepthImageExtractor.cpp
ltm/processors/converter/type/Converter.cpp
ltm/processors/converter/type/object/Converter.cpp
ltm/processors/converter/type/object/json/JsonConverter.cpp
ltm/processors/converter/data/Converter.cpp
ltm/processors/converter/data/object/Converter.cpp
ltm/processors/converter/data/object/json/JsonConverter.cpp
ltm/processors/converter/data/object/bson/BsonConverter.cpp
ltm/processors/converter/data/image/Converter.cpp
ltm/processors/converter/data/image/png/PngConverter.cpp
ltm/processors/converter/data/image/exr/ExrConverter.cpp
ltm/Memory.cpp
ltm/CoreSegment.cpp
ltm/ProviderSegment.cpp
ltm/Entity.cpp
ltm/EntitySnapshot.cpp
ltm/EntityInstance.cpp
ltm/disk/Memory.h
# WM
wm/memory_definitions.cpp
wm/ice_conversions.cpp
wm/detail/MaxHistorySize.cpp
......@@ -128,51 +125,54 @@ set(LIB_HEADERS
MemoryRemoteGui.h
RemoteGuiAronDataVisitor.h
# LTM
ltm/io/Recording.h
ltm/io/Replaying.h
ltm/base/detail/Processors.h
ltm/base/detail/MemoryItem.h
ltm/base/detail/MemoryBase.h
ltm/base/detail/BufferedMemoryBase.h
ltm/base/detail/LUTMemoryBase.h
ltm/base/detail/CoreSegmentBase.h
ltm/base/detail/ProviderSegmentBase.h
ltm/base/detail/EntityBase.h
ltm/base/detail/EntitySnapshotBase.h
ltm/base/filter/Filter.h
ltm/base/filter/frequencyFilter/FrequencyFilter.h
ltm/base/filter/equalityFilter/EqualityFilter.h
ltm/base/extractor/Extractor.h
ltm/base/extractor/imageExtractor/ImageExtractor.h
ltm/base/extractor/imageExtractor/DepthImageExtractor.h
ltm/base/converter/Converter.h
ltm/base/typeConverter/Converter.h
ltm/base/typeConverter/json/JsonConverter.h
ltm/base/converter/object/Converter.h
ltm/base/converter/object/json/JsonConverter.h
ltm/base/converter/object/bson/BsonConverter.h
ltm/base/converter/image/Converter.h
ltm/base/converter/image/png/PngConverter.h
ltm/base/converter/image/exr/ExrConverter.h
ltm/base/forgetter/Forgetter.h
ltm/base/forgetter/LRUForgetter/LRUForgetter.h
ltm/disk/detail/util/util.h
ltm/disk/detail/util/filesystem_util.h
ltm/disk/detail/util/minizip_util.h
ltm/disk/detail/DiskStorage.h
ltm/disk/Memory.h
ltm/disk/CoreSegment.h
ltm/disk/ProviderSegment.h
ltm/disk/Entity.h
ltm/disk/EntitySnapshot.h
ltm/detail/mixins/util/filesystem.h
ltm/detail/mixins/util/mongodb.h
ltm/detail/mixins/CachedMemoryMixin.h
ltm/detail/mixins/BufferedMemoryMixin.h
ltm/detail/mixins/DiskStorageMixin.h
ltm/detail/mixins/MongoDBStorageMixin.h
ltm/detail/MemoryItem.h
ltm/detail/MemoryBase.h
ltm/detail/CoreSegmentBase.h
ltm/detail/ProviderSegmentBase.h
ltm/detail/EntityBase.h
ltm/detail/EntitySnapshotBase.h
ltm/detail/EntityInstanceBase.h
ltm/processors/Processors.h
ltm/processors/filter/Filter.h
ltm/processors/filter/frequencyFilter/FrequencyFilter.h
ltm/processors/filter/equalityFilter/EqualityFilter.h
ltm/processors/extractor/Extractor.h
ltm/processors/extractor/imageExtractor/ImageExtractor.h
ltm/processors/extractor/imageExtractor/DepthImageExtractor.h
ltm/processors/converter/type/Converter.h
ltm/processors/converter/type/object/Converter.h
ltm/processors/converter/type/object/json/JsonConverter.h
ltm/processors/converter/data/Converter.h
ltm/processors/converter/data/object/Converter.h
ltm/processors/converter/data/object/json/JsonConverter.h
ltm/processors/converter/data/object/bson/BsonConverter.h
ltm/processors/converter/data/image/Converter.h
ltm/processors/converter/data/image/png/PngConverter.h
ltm/processors/converter/data/image/exr/ExrConverter.h
ltm/Memory.h
ltm/CoreSegment.h
ltm/ProviderSegment.h
ltm/Entity.h
ltm/EntitySnapshot.h
ltm/EntityInstance.h
# WM
wm/memory_definitions.h
wm/ice_conversions.h
wm/detail/MaxHistorySize.h
......
#include "MemoryToIceAdapter.h"
#include "query_proc/wm/wm.h"
#include "query_proc/ltm/disk/ltm.h"
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
#include <ArmarXCore/core/ice_conversions/ice_conversions_templates.h>
#include <ArmarXCore/core/logging/Logging.h>
#include <ArmarXCore/core/time/ice_conversions.h>
#include <RobotAPI/libraries/aron/core/Exception.h>
#include <RobotAPI/libraries/armem/client/query/Builder.h>
#include <RobotAPI/libraries/armem/core/error.h>
#include <RobotAPI/libraries/armem/core/ice_conversions.h>
#include <RobotAPI/libraries/armem/core/wm/ice_conversions.h>
#include <RobotAPI/libraries/armem/client/query/Builder.h>
#include <RobotAPI/libraries/armem/core/wm/memory_conversions.h>
#include <RobotAPI/libraries/armem/server/wm/ice_conversions.h>
#include <RobotAPI/libraries/aron/core/Exception.h>
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
#include <ArmarXCore/core/ice_conversions/ice_conversions_templates.h>
#include <ArmarXCore/core/logging/Logging.h>
#include <ArmarXCore/core/time/ice_conversions.h>
#include "query_proc/ltm/disk/ltm.h"
#include "query_proc/wm/wm.h"
namespace armarx::armem::server
{
MemoryToIceAdapter::MemoryToIceAdapter(wm::Memory* workingMemory, server::ltm::disk::Memory* longtermMemory) :
MemoryToIceAdapter::MemoryToIceAdapter(wm::Memory* workingMemory,
server::ltm::Memory* longtermMemory) :
workingMemory(workingMemory), longtermMemory(longtermMemory)
{
}
void
MemoryToIceAdapter::setMemoryListener(client::MemoryListenerInterfacePrx memoryListener)
{
this->memoryListenerTopic = memoryListener;
}
// WRITING
data::AddSegmentResult
MemoryToIceAdapter::addSegment(const data::AddSegmentInput& input, bool addCoreSegments)
......@@ -64,22 +62,24 @@ namespace armarx::armem::server
if (input.providerSegmentName.size() > 0)
{
coreSegment->doLocked([&coreSegment, &input]()
{
try
{
coreSegment->addProviderSegment(input.providerSegmentName);
}
catch (const armem::error::ContainerEntryAlreadyExists&)
coreSegment->doLocked(
[&coreSegment, &input]()
{
// This is ok.
if (input.clearWhenExists)
try
{
server::wm::ProviderSegment& provider = coreSegment->getProviderSegment(input.providerSegmentName);
provider.clear();
coreSegment->addProviderSegment(input.providerSegmentName);
}
}
});
catch (const armem::error::ContainerEntryAlreadyExists&)
{
// This is ok.
if (input.clearWhenExists)
{
server::wm::ProviderSegment& provider =
coreSegment->getProviderSegment(input.providerSegmentName);
provider.clear();
}
}
});
}
armem::MemoryID segmentID;
......@@ -92,7 +92,6 @@ namespace armarx::armem::server
return output;
}
data::AddSegmentsResult
MemoryToIceAdapter::addSegments(const data::AddSegmentsInput& input, bool addCoreSegments)
{
......@@ -107,13 +106,12 @@ namespace armarx::armem::server
return output;
}
data::CommitResult
MemoryToIceAdapter::commit(const data::Commit& commitIce, Time timeArrived)
{
ARMARX_TRACE;
ARMARX_CHECK_NOT_NULL(workingMemory);
auto handleException = [](const std::string & what)
auto handleException = [](const std::string& what)
{
data::CommitResult result;
data::EntityUpdateResult& r = result.results.emplace_back();
......@@ -145,7 +143,6 @@ namespace armarx::armem::server
return resultIce;
}
data::CommitResult
MemoryToIceAdapter::commit(const data::Commit& commitIce)
{
......@@ -153,7 +150,6 @@ namespace armarx::armem::server
return commit(commitIce, armem::Time::Now());
}
armem::CommitResult
MemoryToIceAdapter::commit(const armem::Commit& commit)
{
......@@ -161,15 +157,15 @@ namespace armarx::armem::server
return this->_commit(commit, false);
}
armem::CommitResult MemoryToIceAdapter::commitLocking(const armem::Commit& commit)
armem::CommitResult
MemoryToIceAdapter::commitLocking(const armem::Commit& commit)
{
ARMARX_TRACE;
return this->_commit(commit, true);
}
armem::CommitResult MemoryToIceAdapter::_commit(const armem::Commit& commit, bool locking)
armem::CommitResult
MemoryToIceAdapter::_commit(const armem::Commit& commit, bool locking)
{
ARMARX_TRACE;
std::vector<data::MemoryID> updatedIDs;
......@@ -181,9 +177,8 @@ namespace armarx::armem::server
EntityUpdateResult& result = commitResult.results.emplace_back();
try
{
auto updateResult = locking
? workingMemory->updateLocking(update)
: workingMemory->update(update);
auto updateResult =
locking ? workingMemory->updateLocking(update) : workingMemory->update(update);
result.success = true;
result.snapshotID = updateResult.id;
......@@ -200,30 +195,10 @@ namespace armarx::armem::server
//ARMARX_IMPORTANT << longtermMemory->id().str();
//ARMARX_IMPORTANT << longtermMemory->getPath();
// Create Memory out of list TODO: make nicer
// convert removedSnapshots to Memory
armem::wm::Memory m(longtermMemory->name());
for (const auto& snapshot : updateResult.removedSnapshots)
{
if (!m.hasCoreSegment(snapshot.id().coreSegmentName))
{
m.addCoreSegment(snapshot.id().coreSegmentName);
}
auto* c = m.findCoreSegment(snapshot.id().coreSegmentName);
if (!c->hasProviderSegment(snapshot.id().providerSegmentName))
{
c->addProviderSegment(snapshot.id().providerSegmentName);
}
auto* p = c->findProviderSegment(snapshot.id().providerSegmentName);
if (!p->hasEntity(snapshot.id().entityName))
{
p->addEntity(snapshot.id().entityName);
}
auto* e = p->findEntity(snapshot.id().entityName);
armem::wm::toMemory(m, updateResult.removedSnapshots);
e->addSnapshot(snapshot);
}
// store memory
longtermMemory->store(m);
}
......@@ -259,7 +234,6 @@ namespace armarx::armem::server
return commitResult;
}
// READING
armem::query::data::Result
MemoryToIceAdapter::query(const armem::query::data::Input& input)
......@@ -269,12 +243,13 @@ namespace armarx::armem::server
ARMARX_CHECK_NOT_NULL(longtermMemory);
// Core segment processors will aquire the core segment locks.
query_proc::wm_server::MemoryQueryProcessor wmServerProcessor(armem::query::boolToDataMode(input.withData));
query_proc::wm_server::MemoryQueryProcessor wmServerProcessor(
armem::query::boolToDataMode(input.withData));
armem::wm::Memory wmResult = wmServerProcessor.process(input, *workingMemory);
armem::query::data::Result result;
query_proc::ltm_server::disk::MemoryQueryProcessor ltmProcessor;
/*query_proc::ltm_server::MemoryQueryProcessor ltmProcessor;
armem::wm::Memory ltmResult = ltmProcessor.process(input, *longtermMemory);
if (not ltmResult.empty())
......@@ -306,7 +281,7 @@ namespace armarx::armem::server
// mark removed entries of wm in viewer
// TODO
}
}
}*/
result.memory = armarx::toIce<data::MemoryPtr>(wmResult);
......@@ -319,14 +294,15 @@ namespace armarx::armem::server
return result;
}
client::QueryResult MemoryToIceAdapter::query(const client::QueryInput& input)
client::QueryResult
MemoryToIceAdapter::query(const client::QueryInput& input)
{
ARMARX_TRACE;
return client::QueryResult::fromIce(query(input.toIce()));
}
armem::structure::data::GetServerStructureResult MemoryToIceAdapter::getServerStructure()
armem::structure::data::GetServerStructureResult
MemoryToIceAdapter::getServerStructure()
{
ARMARX_TRACE;
ARMARX_CHECK_NOT_NULL(workingMemory);
......@@ -355,11 +331,11 @@ namespace armarx::armem::server
return ret;
}
// LTM LOADING FROM LTM
// LTM STORING AND RECORDING
dto::DirectlyStoreResult MemoryToIceAdapter::directlyStore(const dto::DirectlyStoreInput& directlStoreInput)
dto::DirectlyStoreResult
MemoryToIceAdapter::directlyStore(const dto::DirectlyStoreInput& directlStoreInput)
{
ARMARX_TRACE;
ARMARX_CHECK_NOT_NULL(longtermMemory);
......@@ -373,7 +349,8 @@ namespace armarx::armem::server
return output;
}
dto::StartRecordResult MemoryToIceAdapter::startRecord(const dto::StartRecordInput& startRecordInput)
dto::StartRecordResult
MemoryToIceAdapter::startRecord(const dto::StartRecordInput& startRecordInput)
{
ARMARX_TRACE;
ARMARX_CHECK_NOT_NULL(longtermMemory);
......@@ -386,7 +363,8 @@ namespace armarx::armem::server
return ret;
}
dto::StopRecordResult MemoryToIceAdapter::stopRecord()
dto::StopRecordResult
MemoryToIceAdapter::stopRecord()
{
ARMARX_TRACE;
ARMARX_CHECK_NOT_NULL(longtermMemory);
......@@ -399,24 +377,30 @@ namespace armarx::armem::server
return ret;
}
dto::RecordStatusResult MemoryToIceAdapter::getRecordStatus()
dto::RecordStatusResult
MemoryToIceAdapter::getRecordStatus()
{
dto::RecordStatusResult ret;
ret.success = true;
long savedSnapshots;
long totalSnapshots;
longtermMemory->forEachCoreSegment([&savedSnapshots, &totalSnapshots](const auto& c){
c.forEachProviderSegment([&savedSnapshots, &totalSnapshots](const auto& p){
p.forEachEntity([&savedSnapshots, &totalSnapshots](const auto& e){
savedSnapshots += e.getStatistics().recordedSnapshots;
e.forEachSnapshot([&totalSnapshots](const auto&){
totalSnapshots++;
longtermMemory->forEachCoreSegment(
[&savedSnapshots, &totalSnapshots](const auto& c)
{
c.forEachProviderSegment(
[&savedSnapshots, &totalSnapshots](const auto& p)
{
p.forEachEntity(
[&savedSnapshots, &totalSnapshots](const auto& e)
{
savedSnapshots += e.getStatistics().recordedSnapshots;
e.forEachSnapshot([&totalSnapshots](const auto&)
{ totalSnapshots++; });
});
});
});
});
});
ret.status.savedSnapshots = savedSnapshots;
ret.status.totalSnapshots = totalSnapshots;
......@@ -433,7 +417,8 @@ namespace armarx::armem::server
return armarx::toIce<prediction::data::PredictionResultSeq>(res);
}
prediction::data::EngineSupportMap MemoryToIceAdapter::getAvailableEngines()
prediction::data::EngineSupportMap
MemoryToIceAdapter::getAvailableEngines()
{
prediction::data::EngineSupportMap result;
armarx::toIce(result, workingMemory->getAllPredictionEngines());
......@@ -462,4 +447,4 @@ namespace armarx::armem::server
return result;
}
}
} // namespace armarx::armem::server
#pragma once
#include <RobotAPI/interface/armem/server/MemoryInterface.h>
#include <RobotAPI/interface/armem/client/MemoryListenerInterface.h>
#include <RobotAPI/libraries/armem/core/wm/memory_definitions.h>
#include <RobotAPI/libraries/armem/server/ltm/disk/Memory.h>
#include <RobotAPI/interface/armem/server/MemoryInterface.h>
#include <RobotAPI/libraries/armem/client/Query.h>
#include <RobotAPI/libraries/armem/core/wm/memory_definitions.h>
#include <RobotAPI/libraries/armem/server/ltm/Memory.h>
#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h>
namespace armarx::armem::server
{
......@@ -21,20 +19,19 @@ namespace armarx::armem::server
class MemoryToIceAdapter
{
public:
/// Construct an MemoryToIceAdapter from an existing Memory.
MemoryToIceAdapter(server::wm::Memory* workingMemory = nullptr,
server::ltm::disk::Memory* longtermMemory = nullptr);
server::ltm::Memory* longtermMemory = nullptr);
void setMemoryListener(client::MemoryListenerInterfacePrx memoryListenerTopic);
// WRITING
data::AddSegmentResult addSegment(
const data::AddSegmentInput& input, bool addCoreSegments = false);
data::AddSegmentResult addSegment(const data::AddSegmentInput& input,
bool addCoreSegments = false);
data::AddSegmentsResult addSegments(
const data::AddSegmentsInput& input, bool addCoreSegments = false);
data::AddSegmentsResult addSegments(const data::AddSegmentsInput& input,
bool addCoreSegments = false);
data::CommitResult commit(const data::Commit& commitIce, Time timeArrived);
......@@ -63,18 +60,15 @@ namespace armarx::armem::server
prediction::data::EngineSupportMap getAvailableEngines();
public:
server::wm::Memory* workingMemory;
server::ltm::disk::Memory* longtermMemory;
server::ltm::Memory* longtermMemory;
client::MemoryListenerInterfacePrx memoryListenerTopic;
private:
armem::CommitResult _commit(const armem::Commit& commit, bool locking);
};
}
} // namespace armarx::armem::server
......@@ -2,11 +2,11 @@
#include <RobotAPI/libraries/armem/core/forward_declarations.h>
namespace armarx::armem::server
{
class MemoryToIceAdapter;
}
namespace armarx::armem::server::wm
{
using EntityInstance = armem::wm::EntityInstance;
......@@ -15,12 +15,9 @@ namespace armarx::armem::server::wm
class ProviderSegment;
class CoreSegment;
class Memory;
}
namespace armarx::armem::server::ltm::mongodb
{
class Memory;
}
namespace armarx::armem::server::ltm::disk
} // namespace armarx::armem::server::wm
namespace armarx::armem::server::ltm
{
class Memory;
}