RTI Recording Service  Version 6.1.1
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_RECORDING_SERVICE_HPP_
12 #define RTI_RECORDING_SERVICE_HPP_
13 
14 #include <dds/core/Reference.hpp>
15 #include <rti/config/Logger.hpp>
16 
17 #include <rti/recording/Logger.hpp>
18 #include <rti/recording/ServiceProperty.hpp>
19 #include <rti/recording/detail/RecordingServiceImpl.hpp>
20 
21 namespace rti { namespace recording {
22 
23 /*e \defgroup RTI_RecordingServiceLibModule RTI Recording Service API
24  *
25  * @brief @product can be deployed as a native library linked into your
26  * application in select architectures.
27  *
28  * This API allows you to create, configure and start @product instances from
29  * your application.
30  *
31  * The following code shows the typical use of the API:
32  *
33  * \code
34  *
35  * int main ()
36  * {
37  * rti::recording::Service service(
38  * rti::recording::ServiceProperty()
39  * .cfg_file("MyRecorder.xml")
40  * .service_name("MyRecorder"));
41  * ...
42  *
43  * service.start();
44  *
45  * while(keep_running) {
46  * sleep();
47  * ...
48  * }
49  *
50  * return 0;
51  * }
52  *
53  * \endcode
54  *
55  * Instead of a file, you can use XML strings to configure @product.
56  * See ServiceProperty for more information.
57  * <p>
58  * To build your application you need to link with the @product native library
59  * in <b> &lt;@ndds home&gt;/bin/&lt;architecture&gt;/ </b>.
60  *
61  * ### Development Requirements
62  *
63  * | | Linux Systems | Windows Systems |
64  * | --------------: | :----------------: | :-------------: |
65  * | Shared Libraries| libnddscpp2.so | nddscpp2.dll |
66  * | Shared Libraries| librtiroutingservice.so | rtiroutingservice.dll |
67  * | ^ | librtirsinfrastructure.so | rtirsinfrastructure.dll |
68  * | ^ | librtirecordingservice.so | rtirecordingservice.dll |
69  * | ^ | librtidlc.so | rtidlc.dll |
70  * | ^ | libnddsmetp.so | nddsmetp.dll |
71  * | ^ | libnddsc.so | nddsc.dll |
72  * | ^ | librtixml2.so | rtixml2.dll |
73  * | ^ | libnddscore.so | nddscore.dll |
74  * | Headers | rti/recording/RecordingService.hpp ||
75  *
76  */
77 
83 class Service : public dds::core::Reference<RecordingServiceImpl> {
84 public:
85  typedef RTI::Service::Admin::CommandRequest CommandRequest;
86  typedef RTI::Service::Admin::CommandReply CommandReply;
87 
88  typedef dds::core::Reference<RecordingServiceImpl> Base;
89  OMG_DDS_REF_TYPE_NOTYPENAME(
90  Service,
91  dds::core::Reference,
92  RecordingServiceImpl);
93 
101  explicit Service(const ServiceProperty& property)
102  : Base(new RecordingServiceImpl(property))
103  {
104  this->delegate()->remember_reference(this->delegate());
105  }
106 
153  template <typename HookFunc>
154  explicit Service(
155  const ServiceProperty& property,
156  const HookFunc& shutdown_hook)
157  : Base(new RecordingServiceImpl(
158  property,
159  new rti::routing::detail::ShutdownHookForwarder<HookFunc>(shutdown_hook)))
160  {
161  this->delegate()->remember_reference(this->delegate());
162  }
163 
164 
165  explicit Service(Base::DELEGATE_REF_T reference) : Base(reference)
166  {
167  if (this->delegate()) {
168  this->delegate()->remember_reference(this->delegate());
169  }
170  }
171 
178  void start()
179  {
180  this->delegate()->start();
181  }
182 
188  void stop()
189  {
190  this->delegate()->stop();
191  }
192 
193 
194 
243  CommandReply execute_command(const CommandRequest& request)
244  {
245  return this->delegate()->execute_command(request);
246  }
247 
260  CommandReply& execute_command(
261  CommandReply& reply,
262  const CommandRequest& request)
263  {
264  return this->delegate()->execute_command(reply, request);
265  }
266 
267 
284  static void finalize_globals()
285  {
286  RecordingServiceImpl::finalize_globals();
287  }
288 };
289 
290 
291 typedef Service RecordingService;
292 
293 }}
294 
295 #endif // RTI_RECORDING_SERVICE_HPP_
Service(const ServiceProperty &property, const HookFunc &shutdown_hook)
Creates a RTI Recording Service instance.
Definition: Service.hpp:154
static void finalize_globals()
Finalizes global resources that RTI Recording Service requires to operate.
Definition: Service.hpp:284
Configuration for a RTI Recording Service object.
Definition: ServiceProperty.hpp:105
void start()
Starts RTI Recording Service.
Definition: Service.hpp:178
Service(const ServiceProperty &property)
Creates a RTI Recording Service instance.
Definition: Service.hpp:101
The RTI Recording Service.
Definition: Service.hpp:83
void stop()
Stops RTI Recording Service.
Definition: Service.hpp:188
The RTI namespace.
Definition: RecordingServiceImpl.hpp:22
CommandReply & execute_command(CommandReply &reply, const CommandRequest &request)
Executes an Administration command on this service.
Definition: Service.hpp:260
CommandReply execute_command(const CommandRequest &request)
Executes an Administration command on this service.
Definition: Service.hpp:243