RTI Routing Service Version 7.6.0
Service.hpp
1/*
2 * (c) Copyright, Real-Time Innovations, 2017.
3 * All rights reserved.
4 *
5 * No duplications, whole or partial, manual or electronic, may be made
6 * without express written permission. Any such copies, or
7 * revisions thereof, must display this notice unaltered.
8 * This code contains trade secrets of Real-Time Innovations, Inc.
9 */
10
11#ifndef RTI_ROUTING_SERVICE_HPP_
12#define RTI_ROUTING_SERVICE_HPP_
13
14#include <dds/core/Reference.hpp>
15#include <rti/config/Logger.hpp>
16
17#include "routingservice/routingservice_adapter_new.h"
18
19#include <rti/routing/Logger.hpp>
20#include <rti/routing/ServiceProperty.hpp>
21#include <rti/routing/detail/RoutingServiceImpl.hpp>
24
25namespace rti { namespace routing {
26
27/*e \defgroup RTI_RoutingServiceLibModule RTI Routing Library API
28 * \ingroup ROUTER
29 *
30 * @brief @product can be deployed as a native library linked into your
31 * application in select architectures.
32 *
33 * This API allows you to create, configure and start @product instances from
34 * your application.
35 *
36 * The following code shows the typical use of the API:
37 *
38 * \code
39 *
40 * int main ()
41 * {
42 * rti::routing::Service service(
43 * rti::routing::ServiceProperty()
44 * .cfg_file("MyRouter.xml")
45 * .cfg_name("MyRouter"));
46 * ...
47 *
48 * service.start();
49 *
50 * while(keep_running) {
51 * sleep();
52 * ...
53 * }
54 *
55 * return 0;
56 * }
57 *
58 * \endcode
59 *
60 * Instead of a file, you can use XML strings to configure @product.
61 * See ServiceProperty for more information.
62 * <p>
63 * To build your application you need to link with the @product native library
64 * in <b> &lt;@ndds home&gt;/bin/&lt;architecture&gt;/ </b>.
65 *
66 * ### Development Requirements
67 *
68 * | | Linux/macOS Systems | Windows Systems |
69 * | --------------: | :----------------: | :-------------: |
70 * | Shared Libraries| libnddscpp2.so | nddscpp2.dll |
71 * | ^ | librtirsinfrastructure.so | rtirsinfrastructure.dll |
72 * | ^ | librtiserviceadmincpp.so | rtiserviceadmincpp.dll |
73 * | ^ | librtidlc.so | rtidlc.dll |
74 * | ^ | librtiapputilsc.so | rtiapputilsc.dll |
75 * | ^ | libnddsmetp.so | nddsmetp.dll |
76 * | ^ | librticonnextmsgc.so | rticonnextmsgc.dll |
77 * | ^ | libnddsc.so | nddsc.dll |
78 * | ^ | librtixml2.so | rtixml2.dll |
79 * | ^ | libnddscore.so | nddscore.dll |
80 * | Headers | rti/routing/RoutingService.hpp ||
81 *
82 */
83
89class Service : public dds::core::Reference<RoutingServiceImpl> {
90public:
91
92 typedef RTI::Service::Admin::CommandRequest CommandRequest;
93 typedef RTI::Service::Admin::CommandReply CommandReply;
94
95 typedef dds::core::Reference<RoutingServiceImpl> Base;
96 OMG_DDS_REF_TYPE_NOTYPENAME(
97 Service,
98 dds::core::Reference,
99 RoutingServiceImpl);
100
113 explicit Service(const ServiceProperty& property)
114 : Base(new RoutingServiceImpl(property))
115 {
116 this->delegate()->remember_reference(this->delegate());
117 }
118
170 template <typename HookFunc>
172 const ServiceProperty& property,
173 HookFunc& shutdown_hook)
174 : Base(new RoutingServiceImpl(property, shutdown_hook))
175 {
176 this->delegate()->remember_reference(this->delegate());
177 }
178
179 Service(const RTI_RoutingServiceProperty& property)
180 : Base(new RoutingServiceImpl(property))
181 {
182 this->delegate()->remember_reference(this->delegate());
183 }
184
185 explicit Service(Base::DELEGATE_REF_T reference) : Base(reference)
186 {
187 if (this->delegate()) {
188 this->delegate()->remember_reference(this->delegate());
189 }
190 }
191
198 void start()
199 {
200 this->delegate()->start();
201 }
202
208 void stop()
209 {
210 this->delegate()->stop();
211 }
212
277 const std::string& plugin_name)
278 {
279 this->delegate()->attach_adapter_plugin(
280 adapter_plugin,
281 plugin_name);
282 }
283
292 const std::string& plugin_name)
293 {
294 this->delegate()->attach_processor_plugin(
295 processor_plugin,
296 plugin_name);
297 }
298
306 rti::routing::transf::TransformationPlugin *transformation_plugin,
307 const std::string& plugin_name)
308 {
309 this->delegate()->attach_transformation_plugin(
310 transformation_plugin,
311 plugin_name);
312 }
313
362 CommandReply execute_command(const CommandRequest& request)
363 {
364 return this->delegate()->execute_command(request);
365 }
366
379 CommandReply& execute_command(
380 CommandReply& reply,
381 const CommandRequest& request)
382 {
383 return this->delegate()->execute_command(reply, request);
384 }
385
390 static void finalize_globals()
391 {
392 rti::routing::Logger::instance().warn(
393 "Calling 'rti::routing::Service::finalize_globals()' is no "
394 "longer necessary and the function will be removed in future "
395 "versions");
396 }
397
398};
399
400typedef Service RoutingService;
401
402}}
403
404#endif // RTI_ROUTING_SERVICE_HPP_
RTI Routing Service C++ Adapter API.
RTI Routing Service C++ Processor API.
void warn(const std::string &msg)
Logs as message with WARNING level.
Definition: Logger.hpp:110
Configuration for a RTI Routing Service object.
Definition: ServiceProperty.hpp:114
The RTI Routing Service.
Definition: Service.hpp:89
CommandReply & execute_command(CommandReply &reply, const CommandRequest &request)
Executes an Administration command on this service.
Definition: Service.hpp:379
Service(const ServiceProperty &property, HookFunc &shutdown_hook)
Creates a RTI Routing Service instance.
Definition: Service.hpp:171
static void finalize_globals()
Definition: Service.hpp:390
void attach_processor_plugin(rti::routing::processor::ProcessorPlugin *processor_plugin, const std::string &plugin_name)
Attaches a Processor plugin to be used by RTI Routing Service when it is started.
Definition: Service.hpp:290
void start()
Starts RTI Routing Service.
Definition: Service.hpp:198
CommandReply execute_command(const CommandRequest &request)
Executes an Administration command on this service.
Definition: Service.hpp:362
void attach_transformation_plugin(rti::routing::transf::TransformationPlugin *transformation_plugin, const std::string &plugin_name)
Attaches a Transformation plugin to be used by RTI Routing Service when it is started.
Definition: Service.hpp:305
void stop()
Stops RTI Routing Service.
Definition: Service.hpp:208
void attach_adapter_plugin(rti::routing::adapter::AdapterPlugin *adapter_plugin, const std::string &plugin_name)
Attaches an Adapter plugin to be used by RTI Routing Service when it is started.
Definition: Service.hpp:275
Service(const ServiceProperty &property)
Creates a RTI Routing Service instance.
Definition: Service.hpp:113
The top-level plug-in class.
Definition: AdapterPlugin.hpp:34
The top-level plug-in class.
Definition: ProcessorPlugin.hpp:202
The top-level plug-in class.
Definition: TransformationPlugin.hpp:44