RTI Routing Service  Version 6.1.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 
25 namespace rti { namespace routing {
26 
27 /*e \defgroup RTI_RoutingServiceLibModule RTI Routing Service 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  * | ^ | librtidlc.so | rtidlc.dll |
73  * | ^ | libnddsmetp.so | nddsmetp.dll |
74  * | ^ | libnddsc.so | nddsc.dll |
75  * | ^ | librtixml2.so | rtixml2.dll |
76  * | ^ | libnddscore.so | nddscore.dll |
77  * | Headers | rti/routing/RoutingService.hpp ||
78  *
79  */
80 
86 class Service : public dds::core::Reference<RoutingServiceImpl> {
87 public:
88  typedef dds::core::Reference<RoutingServiceImpl> Base;
89  OMG_DDS_REF_TYPE_NOTYPENAME(
90  Service,
91  dds::core::Reference,
92  RoutingServiceImpl);
93 
101  explicit Service(
102  const ServiceProperty& property)
103  : Base(new RoutingServiceImpl(property, detail::NoopShutdownHook()))
104  {
105  this->delegate()->remember_reference(this->delegate());
106  }
107 
154  template <typename HookFunc>
156  const ServiceProperty& property,
157  const HookFunc& shutdown_hook)
158  : Base(new RoutingServiceImpl(property, shutdown_hook))
159  {
160  this->delegate()->remember_reference(this->delegate());
161  }
162 
163  Service(const RTI_RoutingServiceProperty& property)
164  : Base(new RoutingServiceImpl(property))
165  {
166  this->delegate()->remember_reference(this->delegate());
167  }
168 
169  explicit Service(Base::DELEGATE_REF_T reference) : Base(reference)
170  {
171  if (this->delegate()) {
172  this->delegate()->remember_reference(this->delegate());
173  }
174  }
175 
182  void start()
183  {
184  this->delegate()->start();
185  }
186 
192  void stop()
193  {
194  this->delegate()->stop();
195  }
196 
260  rti::routing::adapter::AdapterPlugin *adapter_plugin,
261  const std::string& plugin_name)
262  {
263  this->delegate()->attach_adapter_plugin(
264  adapter_plugin,
265  plugin_name);
266  }
267 
276  const std::string& plugin_name)
277  {
278  this->delegate()->attach_processor_plugin(
279  processor_plugin,
280  plugin_name);
281  }
282 
290  rti::routing::transf::TransformationPlugin *transformation_plugin,
291  const std::string& plugin_name)
292  {
293  this->delegate()->attach_transformation_plugin(
294  transformation_plugin,
295  plugin_name);
296  }
297 
298 
315  static void finalize_globals()
316  {
317  RoutingServiceImpl::finalize_globals();
318  }
319 
320 };
321 
322 typedef Service RoutingService;
323 
324 }}
325 
326 #endif // RTI_ROUTING_SERVICE_HPP_
Service(const ServiceProperty &property, const HookFunc &shutdown_hook)
Creates a RTI Routing Service instance.
Definition: Service.hpp:155
The top-level plug-in class.
Definition: ProcessorPlugin.hpp:202
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:289
The RTI Routing Service.
Definition: Service.hpp:86
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:259
static void finalize_globals()
Finalizes global resources that RTI Routing Service requires to operate.
Definition: Service.hpp:315
Service(const ServiceProperty &property)
Creates a RTI Routing Service instance.
Definition: Service.hpp:101
The top-level plug-in class.
Definition: AdapterPlugin.hpp:34
void start()
Starts RTI Routing Service.
Definition: Service.hpp:182
RTI Routing Service C++ Processor API.
Configuration for a RTI Routing Service object.
Definition: ServiceProperty.hpp:114
The top-level plug-in class.
Definition: TransformationPlugin.hpp:44
void stop()
Stops RTI Routing Service.
Definition: Service.hpp:192
Definition: AdapterPlugin.hpp:25
RTI Routing Service C++ Adapter API.
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:274