RTI Routing Service  Version 7.0.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 
106  explicit Service(
107  const ServiceProperty& property)
108  : Base(new RoutingServiceImpl(property, detail::NoopShutdownHook()))
109  {
110  this->delegate()->remember_reference(this->delegate());
111  }
112 
164  template <typename HookFunc>
166  const ServiceProperty& property,
167  const HookFunc& shutdown_hook)
168  : Base(new RoutingServiceImpl(property, shutdown_hook))
169  {
170  this->delegate()->remember_reference(this->delegate());
171  }
172 
173  Service(const RTI_RoutingServiceProperty& property)
174  : Base(new RoutingServiceImpl(property))
175  {
176  this->delegate()->remember_reference(this->delegate());
177  }
178 
179  explicit Service(Base::DELEGATE_REF_T reference) : Base(reference)
180  {
181  if (this->delegate()) {
182  this->delegate()->remember_reference(this->delegate());
183  }
184  }
185 
192  void start()
193  {
194  this->delegate()->start();
195  }
196 
202  void stop()
203  {
204  this->delegate()->stop();
205  }
206 
270  rti::routing::adapter::AdapterPlugin *adapter_plugin,
271  const std::string& plugin_name)
272  {
273  this->delegate()->attach_adapter_plugin(
274  adapter_plugin,
275  plugin_name);
276  }
277 
286  const std::string& plugin_name)
287  {
288  this->delegate()->attach_processor_plugin(
289  processor_plugin,
290  plugin_name);
291  }
292 
300  rti::routing::transf::TransformationPlugin *transformation_plugin,
301  const std::string& plugin_name)
302  {
303  this->delegate()->attach_transformation_plugin(
304  transformation_plugin,
305  plugin_name);
306  }
307 
308 
313  static void finalize_globals()
314  {
315  rti::routing::Logger::instance().warn(
316  "Calling 'rti::routing::Service::finalize_globals()' is no "
317  "longer necessary and the function will be removed in future "
318  "versions");
319  }
320 
321 };
322 
323 typedef Service RoutingService;
324 
325 }}
326 
327 #endif // RTI_ROUTING_SERVICE_HPP_
Service(const ServiceProperty &property, const HookFunc &shutdown_hook)
Creates a RTI Routing Service instance.
Definition: Service.hpp:165
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:299
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:269
static void finalize_globals()
Definition: Service.hpp:313
Service(const ServiceProperty &property)
Creates a RTI Routing Service instance.
Definition: Service.hpp:106
The top-level plug-in class.
Definition: AdapterPlugin.hpp:34
void start()
Starts RTI Routing Service.
Definition: Service.hpp:192
RTI Routing Service C++ Processor API.
Configuration for a RTI Routing Service object.
Definition: ServiceProperty.hpp:114
void warn(const std::string &msg)
Logs as message with WARNING level.
Definition: Logger.hpp:110
The top-level plug-in class.
Definition: TransformationPlugin.hpp:44
void stop()
Stops RTI Routing Service.
Definition: Service.hpp:202
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:284