SimpleWriterBase.cpp
Go to the documentation of this file.
1
#include "
SimpleWriterBase.h
"
2
3
#include <
RobotAPI/libraries/armem/client/MemoryNameSystem.h
>
4
#include <
RobotAPI/libraries/armem/core/error.h
>
5
6
namespace
armarx::armem::client::util
7
{
8
SimpleWriterBase::SimpleWriterBase
()
9
{
10
}
11
12
void
13
SimpleWriterBase::registerPropertyDefinitions
(
armarx::PropertyDefinitionsPtr
& def)
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
33
SimpleWriterBase::connect
(
armarx::armem::client::MemoryNameSystem
& mns)
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
}
43
catch
(
const
armem::error::CouldNotResolveMemoryServer
& e)
44
{
45
ARMARX_ERROR
<< e.what();
46
return
;
47
}
48
}
49
50
armem::client::Writer
&
51
SimpleWriterBase::memoryWriter
()
52
{
53
return
memoryWriterClient;
54
}
55
56
const
SimpleWriterBase::Properties
&
57
SimpleWriterBase::properties
()
const
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
67
SimpleWriterBase::setProperties
(
const
Properties
& p)
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
RobotAPI
libraries
armem
client
util
SimpleWriterBase.cpp
Generated on Sat Oct 12 2024 09:14:08 for armarx_documentation by
1.8.17