SimpleWriterBase.cpp
Go to the documentation of this file.
1 #include "SimpleWriterBase.h"
2 
5 
7 {
9  {
10  }
11 
12  void
14  {
15  ARMARX_DEBUG << "Writer: registerPropertyDefinitions";
16 
17  const std::string prefix = propertyPrefix();
18 
19  if (not props.has_value())
20  {
21  props = defaultProperties();
22  }
23 
24  def->optional(props->memoryName, prefix + "Memory");
25  def->optional(props->coreSegmentName, prefix + "CoreSegment");
26 
27  // TODO(fabian.reister): this might also be part of the subclass
28  // if the provider name has to be derived from e.g. the component name
29  def->optional(props->providerName, prefix + "Provider", "Name of this provider");
30  }
31 
32  void
34  {
35  // Wait for the memory to become available and add it as dependency.
36  ARMARX_IMPORTANT << "SimpleWriterBase: Waiting for memory '" << properties().memoryName << "' ...";
37  try
38  {
39  memoryWriterClient = mns.useWriter(MemoryID().withMemoryName(properties().memoryName));
40  ARMARX_IMPORTANT << "SimpleWriterBase: Connected to memory '" << properties().memoryName
41  << "'";
42  }
44  {
45  ARMARX_ERROR << e.what();
46  return;
47  }
48  }
49 
52  {
53  return memoryWriterClient;
54  }
55 
58  {
59  if (not props.has_value())
60  {
61  const_cast<std::optional<Properties>&>(props) = defaultProperties();
62  }
63  return props.value();
64  }
65 
66  void
68  {
69  props = p;
70  }
71 
72 } // namespace armarx::armem::client::util
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::armem::client::util::SimpleWriterBase::setProperties
void setProperties(const Properties &p)
Definition: SimpleWriterBase.cpp:67
armarx::armem::client::util::SimpleWriterBase::defaultProperties
virtual Properties defaultProperties() const =0
armarx::armem::client::MemoryNameSystem::useWriter
Writer useWriter(const MemoryID &memoryID)
Use a memory server and get a writer for it.
Definition: MemoryNameSystem.cpp:276
armarx::armem::client::util::SimpleWriterBase::Properties
Definition: SimpleWriterBase.h:49
armarx::armem::client::util::SimpleWriterBase::SimpleWriterBase
SimpleWriterBase()
Definition: SimpleWriterBase.cpp:8
armarx::armem::client::util::SimpleWriterBase::registerPropertyDefinitions
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Definition: SimpleWriterBase.cpp:13
armarx::armem::client::util::SimpleWriterBase::memoryWriter
armem::client::Writer & memoryWriter()
Definition: SimpleWriterBase.cpp:51
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::armem::client::util::SimpleWriterBase::Properties::memoryName
std::string memoryName
Definition: SimpleWriterBase.h:51
error.h
armarx::armem::client::util::SimpleWriterBase::connect
void connect(armarx::armem::client::MemoryNameSystem &mns)
Definition: SimpleWriterBase.cpp:33
armarx::armem::client::Writer
Helps a memory client sending data to a memory.
Definition: Writer.h:22
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::armem::laser_scans::constants::memoryName
const std::string memoryName
Definition: constants.h:28
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::armem::client::util
Definition: MemoryListener.cpp:13
armarx::armem::client::util::SimpleWriterBase::properties
const Properties & properties() const
Definition: SimpleWriterBase.cpp:57
armarx::armem::client::util::SimpleWriterBase::propertyPrefix
virtual std::string propertyPrefix() const =0
armarx::armem::client::MemoryNameSystem
The memory name system (MNS) client.
Definition: MemoryNameSystem.h:69
armarx::armem::error::CouldNotResolveMemoryServer
Indicates that a query to the Memory Name System failed.
Definition: mns.h:26
MemoryNameSystem.h
SimpleWriterBase.h
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29