ComponentPlugin.cpp
Go to the documentation of this file.
1#include <memory>
2#include <string>
3
9
12
19
20// ComponentPlugin
21
23{
24
26
27 void
29 {
30 if (not properties->hasDefinition(PROPERTY_NAME))
31 {
32 properties->defineOptionalProperty<std::string>(
33 PROPERTY_NAME, "navigator", "Name of the Navigator");
34 }
35 }
36
37 void
39 {
41 parent<armarx::Component>().usingProxyFromProperty(PROPERTY_NAME);
42 }
43
44 void
46 {
48 parent<armarx::Component>().getProxyFromProperty(navigatorPrx, PROPERTY_NAME);
49
51 const std::string componentName = parent().getName();
52
53 ARMARX_CHECK_NOT_NULL(navigatorPrx) << "Navigator proxy is null!";
54 iceNavigatorFactory.setNavigatorComponent(navigatorPrx);
55 }
56
57 void
59 const std::string& configId)
60 {
62
63 // ARMARX_CHECK_NULL(eventHandler) << "`configureNavigator()` can only be called once!";
64
65 eventHandler = [&]() -> std::unique_ptr<SimpleEventHandler>
66 {
69 {
71 ARMARX_INFO << "Using memory event callbacks.";
72 // must(!!) use a reference here: otherwise the mns events won't work
73 auto& memoryNameSystem =
75 .memoryNameSystem();
76 return std::make_unique<MemorySubscriber>(configId, memoryNameSystem);
77 }
78
80 << "Cannot use memory event callbacks as this component is not derived from "
81 "`armarx::armem::client::plugins::ListeningPluginUser`";
82
83 return std::make_unique<SimpleEventHandler>();
84 }();
85
86 iceNavigatorHandle = iceNavigatorFactory.createConfig(stackConfig, configId);
87
88 navigator = std::make_unique<Navigator>(Navigator::InjectedServices{
89 .navigator = iceNavigatorHandle.get(), .subscriber = eventHandler.get()});
90 }
91
92 // ComponentPluginUser
93
99
100 void
102 {
104 plugin->configureNavigator(stackConfig, getName());
105 }
106
107 Navigator&
109 {
110 ARMARX_CHECK_NOT_NULL(plugin->navigator)
111 << "You need to call `configureNavigator()` before you can access the navigator!";
112 return *plugin->navigator;
113 }
114
116
117} // namespace armarx::navigation::client
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
std::string getName() const
Retrieve name of object.
void configureNavigator(const client::NavigationStackConfig &stackConfig)
void configureNavigator(const client::NavigationStackConfig &stackConfig, const std::string &configId)
void postCreatePropertyDefinitions(armarx::PropertyDefinitionsPtr &properties) override
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file is part of ArmarX.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
#define ARMARX_TRACE
Definition trace.h:77