Skip to content
Snippets Groups Projects
Commit 7bb2566c authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

fix properties of simpleWriter if no registerPropertyDefinitions is used

parent 93da6533
No related branches found
No related tags found
No related merge requests found
......@@ -16,25 +16,28 @@ namespace armarx::armem::client::util
const std::string prefix = propertyPrefix();
props = defaultProperties();
if (not props.has_value())
{
props = defaultProperties();
}
def->optional(props.memoryName, prefix + "Memory");
def->optional(props.coreSegmentName, prefix + "CoreSegment");
def->optional(props->memoryName, prefix + "Memory");
def->optional(props->coreSegmentName, prefix + "CoreSegment");
// TODO(fabian.reister): this might also be part of the subclass
// if the provider name has to be derived from e.g. the component name
def->optional(props.providerName, prefix + "Provider", "Name of this provider");
def->optional(props->providerName, prefix + "Provider", "Name of this provider");
}
void
SimpleWriterBase::connect(armarx::armem::client::MemoryNameSystem& mns)
{
// Wait for the memory to become available and add it as dependency.
ARMARX_IMPORTANT << "SimpleWriterBase: Waiting for memory '" << props.memoryName << "' ...";
ARMARX_IMPORTANT << "SimpleWriterBase: Waiting for memory '" << properties().memoryName << "' ...";
try
{
memoryWriterClient = mns.useWriter(MemoryID().withMemoryName(props.memoryName));
ARMARX_IMPORTANT << "SimpleWriterBase: Connected to memory '" << props.memoryName
memoryWriterClient = mns.useWriter(MemoryID().withMemoryName(properties().memoryName));
ARMARX_IMPORTANT << "SimpleWriterBase: Connected to memory '" << properties().memoryName
<< "'";
}
catch (const armem::error::CouldNotResolveMemoryServer& e)
......@@ -53,7 +56,17 @@ namespace armarx::armem::client::util
const SimpleWriterBase::Properties&
SimpleWriterBase::properties() const
{
return props;
if (not props.has_value())
{
const_cast<std::optional<Properties>&>(props) = defaultProperties();
}
return props.value();
}
void
SimpleWriterBase::setProperties(const Properties& p)
{
props = p;
}
} // namespace armarx::armem::client::util
......@@ -54,6 +54,7 @@ namespace armarx::armem::client::util
};
const Properties& properties() const;
void setProperties(const Properties& p);
virtual std::string propertyPrefix() const = 0;
virtual Properties defaultProperties() const = 0;
......@@ -62,7 +63,7 @@ namespace armarx::armem::client::util
private:
Properties props;
std::optional<Properties> props;
armem::client::Writer memoryWriterClient;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment