Writer.cpp
Go to the documentation of this file.
1 #include "Writer.h"
2 
4 
7 
8 
10 {
11  bool
12  Writer::store(const std::unordered_map<core::StackLayer, aron::data::DictPtr>& stack,
13  const std::string& clientID,
14  const armarx::core::time::DateTime& timestamp)
15  {
16  ARMARX_CHECK(not stack.empty());
17 
18  armem::Commit commit;
19 
20  for (const auto& [layer, data] : stack)
21  {
22  const std::string layerName = core::StackLayerNames.to_name(layer);
23 
25  update.entityID = armem::MemoryID()
27  .withCoreSegmentName(properties().coreSegmentName)
28  .withProviderSegmentName(clientID)
29  .withEntityName(layerName)
30  .withTimestamp(timestamp);
31  update.referencedTime = timestamp;
32  update.instancesData = {data};
33  commit.add(update);
34  }
35 
36  std::lock_guard g{writeMutex};
37  armem::CommitResult updateResult = memoryWriter().commit(commit);
38 
39  ARMARX_DEBUG << updateResult;
40 
41  if (not updateResult.allSuccess())
42  {
43  ARMARX_ERROR << updateResult.allErrorMessages();
44  }
45  return updateResult.allSuccess();
46  }
47 
48  std::string
50  {
51  return "mem.nav.param.";
52  }
53 
56  {
57  return Properties{
60  .providerName = "" // clientId
61  };
62  }
63 
64 } // namespace armarx::navigation::memory::client::param
armarx::armem::MemoryID::withMemoryName
MemoryID withMemoryName(const std::string &name) const
Definition: MemoryID.cpp:396
armarx::armem::Commit
A bundle of updates to be sent to the memory.
Definition: Commit.h:89
armarx::navigation::memory::client::param
This file is part of ArmarX.
Definition: Reader.cpp:5
armarx::navigation::memory::client::param::Writer::propertyPrefix
std::string propertyPrefix() const override
Definition: Writer.cpp:49
armarx::armem::client::util::SimpleWriterBase::Properties
Definition: SimpleWriterBase.h:49
armarx::navigation::memory::client::param::Writer::store
bool store(const std::unordered_map< core::StackLayer, aron::data::DictPtr > &stack, const std::string &clientID, const armarx::core::time::DateTime &timestamp)
Definition: Writer.cpp:12
armarx::navigation::memory::constants::NavigationMemoryName
const std::string NavigationMemoryName
Definition: constants.h:27
constants.h
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::armem::MemoryID::withProviderSegmentName
MemoryID withProviderSegmentName(const std::string &name) const
Definition: MemoryID.cpp:412
armarx::armem::client::util::SimpleWriterBase::memoryWriter
armem::client::Writer & memoryWriter()
Definition: SimpleWriterBase.cpp:51
armarx::navigation::core::StackLayerNames
const simox::meta::EnumNames< StackLayer > StackLayerNames
Definition: constants.h:41
armarx::armem::MemoryID::withCoreSegmentName
MemoryID withCoreSegmentName(const std::string &name) const
Definition: MemoryID.cpp:404
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::armem::client::util::SimpleWriterBase::Properties::memoryName
std::string memoryName
Definition: SimpleWriterBase.h:51
armarx::armem::EntityUpdate
An update of an entity for a specific point in time.
Definition: Commit.h:27
armarx::armem::CommitResult
Result of a Commit.
Definition: Commit.h:110
All.h
armarx::armem::client::Writer::commit
CommitResult commit(const Commit &commit) const
Writes a Commit to the memory.
Definition: Writer.cpp:59
Writer.h
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::armem::MemoryID::withEntityName
MemoryID withEntityName(const std::string &name) const
Definition: MemoryID.cpp:420
armarx::armem::Commit::add
EntityUpdate & add()
Definition: Commit.cpp:81
armarx::armem::laser_scans::constants::memoryName
const std::string memoryName
Definition: constants.h:28
armarx::navigation::memory::client::param::Writer::defaultProperties
Properties defaultProperties() const override
Definition: Writer.cpp:55
armarx::armem::client::util::SimpleWriterBase::properties
const Properties & properties() const
Definition: SimpleWriterBase.cpp:57
armarx::armem::MemoryID::withTimestamp
MemoryID withTimestamp(Time time) const
Definition: MemoryID.cpp:428
armarx::navigation::memory::constants::ParameterizationCoreSegmentName
const std::string ParameterizationCoreSegmentName
Definition: constants.h:30
constants.h
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29