SimpleWriterBase.cpp
Go to the documentation of this file.
1#include "SimpleWriterBase.h"
2
5
7{
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 << "' ...";
38 try
39 {
40 memoryWriterClient = mns.useWriter(MemoryID().withMemoryName(properties().memoryName));
41 ARMARX_IMPORTANT << "SimpleWriterBase: Connected to memory '" << properties().memoryName
42 << "'";
43 }
45 {
46 ARMARX_ERROR << e.what();
47 return;
48 }
49 }
50
53 {
54 return memoryWriterClient;
55 }
56
59 {
60 if (not props.has_value())
61 {
62 const_cast<std::optional<Properties>&>(props) = defaultProperties();
63 }
64 return props.value();
65 }
66
67 void
69 {
70 props = p;
71 }
72
73} // namespace armarx::armem::client::util
The memory name system (MNS) client.
Helps a memory client sending data to a memory.
Definition Writer.h:23
virtual Properties defaultProperties() const =0
virtual std::string propertyPrefix() const =0
void connect(armarx::armem::client::MemoryNameSystem &mns)
void registerPropertyDefinitions(armarx::PropertyDefinitionsPtr &def)
Indicates that a query to the Memory Name System failed.
Definition mns.h:25
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
Definition Logging.h:184
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.