19 ctx[
"clientPid"] = std::to_string(getpid());
20 this->memory =
memory->ice_context(ctx);
24 data::AddSegmentResult
26 const std::string& providerSegmentName,
27 bool clearWhenExists)
const
29 data::AddSegmentInput input;
30 input.coreSegmentName = coreSegmentName;
31 input.providerSegmentName = providerSegmentName;
32 input.clearWhenExists = clearWhenExists;
36 data::AddSegmentResult
44 data::AddSegmentResult
47 return addSegment(names.first, names.second, clearWhenExists);
50 data::AddSegmentResult
53 data::AddSegmentsResult results =
addSegments({input});
58 data::AddSegmentsResult
62 data::AddSegmentsResult results =
memory->addSegments(inputs);
72 data::Commit commitIce;
75 data::CommitResult resultIce = this->_commit(commitIce);
86 data::Commit
commit = _commit;
87 return this->_commit(
commit);
94 commit.updates.push_back(update);
103 const std::vector<aron::data::DictPtr>& instancesData,
105 const std::string& origin)
const
108 update.entityID = entityID;
109 update.instancesData = instancesData;
110 update.referencedTime = referencedTime;
111 update.origin = origin;
117 memory->clearWorkingMemory();
127 Writer::_commit(data::Commit& commit)
const
141 for (data::EntityUpdate& update :
commit.updates)
143 toIce(update.timeSent, timeSent);
146 data::CommitResult result;
147 auto handleError = [&
commit, &result](
const std::string& what)
149 for (
const auto& _ :
commit.updates)
152 data::EntityUpdateResult& r = result.results.emplace_back();
154 r.errorMessage =
"Memory component not registered.\n" + std::string(what);
162 catch (
const Ice::ConnectionRefusedException& e)
164 handleError(e.what());
166 catch (
const Ice::ConnectionLostException& e)
168 handleError(e.what());
170 catch (
const Ice::NotRegisteredException& e)
172 handleError(e.what());
182 return os <<
"AddSegmentInput: "
183 <<
"\n- core segment: \t'" << rhs.coreSegmentName <<
"'"
184 <<
"\n- provider segment: \t'" << rhs.providerSegmentName <<
"'"
185 <<
"\n- clear when exists:\t" << rhs.clearWhenExists <<
""
192 for (
size_t i = 0; i < rhs.size(); ++i)
194 os <<
"[" << i <<
"] " << rhs[i];
202 return os <<
"AddSegmentResult:"
203 <<
"\n- success: \t" << rhs.success <<
"\n- segment ID: \t'" << rhs.segmentID
205 <<
"\n- error message: \t" << rhs.errorMessage <<
"\n";
211 for (
size_t i = 0; i < rhs.size(); ++i)
213 os <<
"[" << i <<
"] " << rhs[i];
std::string coreSegmentName
std::string providerSegmentName
void clearWorkingMemory()
Clears the servers working memory (uses the WM-Clear feature)
server::WritingMemoryInterfacePrx memory
void setWritingMemory(server::WritingMemoryInterfacePrx memory)
data::AddSegmentResult addSegment(const std::string &coreSegmentName, const std::string &providerSegmentName, bool clearWhenExists=false) const
Writer(const Writer &)=default
Construct a memory writer.
CommitResult commit(const Commit &commit) const
Writes a Commit to the memory.
data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input) const
Brief description of class memory.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
This file is part of ArmarX.
void fromIce(const armem::query::data::Input &ice, QueryInput &input)
void toIce(armem::query::data::Input &ice, const QueryInput &input)
std::ostream & operator<<(std::ostream &os, const AddSegmentInput &rhs)
armarx::core::time::DateTime Time
std::vector< EntityUpdateResult > results
A bundle of updates to be sent to the memory.
Result of an EntityUpdate.
An update of an entity for a specific point in time.