RTI Recording Service Version 7.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_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
21namespace rti { namespace recording {
22
23/*e \defgroup RTI_RecordingServiceLibModule RTI Recording Library 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
83class Service : public dds::core::Reference<RecordingServiceImpl> {
84public:
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
106 explicit Service(const ServiceProperty& property)
107 : Base(new RecordingServiceImpl(property))
108 {
109 this->delegate()->remember_reference(this->delegate());
110 }
111
163 template <typename HookFunc>
164 explicit Service(
165 const ServiceProperty& property,
166 const HookFunc& shutdown_hook)
167 : Base(new RecordingServiceImpl(
168 property,
169 new rti::routing::detail::ShutdownHookForwarder<HookFunc>(
170 shutdown_hook)))
171 {
172 this->delegate()->remember_reference(this->delegate());
173 }
174
175
176 explicit Service(Base::DELEGATE_REF_T reference) : Base(reference)
177 {
178 if (this->delegate()) {
179 this->delegate()->remember_reference(this->delegate());
180 }
181 }
182
189 void start()
190 {
191 this->delegate()->start();
192 }
193
199 void stop()
200 {
201 this->delegate()->stop();
202 }
203
204
205
254 CommandReply execute_command(const CommandRequest& request)
255 {
256 return this->delegate()->execute_command(request);
257 }
258
271 CommandReply& execute_command(
272 CommandReply& reply,
273 const CommandRequest& request)
274 {
275 return this->delegate()->execute_command(reply, request);
276 }
277
282 static void finalize_globals()
283 {
284 rti::recording::Logger::instance().warn(
285 "Calling 'rti::recording::Service::finalize_globals()' is no "
286 "longer necessary and the function will be removed in future "
287 "versions");
288 }
289};
290
291
292typedef Service RecordingService;
293
294}}
295
296#endif // RTI_RECORDING_SERVICE_HPP_
void warn(const std::string &msg)
Logs as message with WARNING level.
Configuration for a RTI Recording Service object.
Definition: ServiceProperty.hpp:105
The RTI Recording Service.
Definition: Service.hpp:83
void start()
Starts RTI Recording Service.
Definition: Service.hpp:189
static void finalize_globals()
Definition: Service.hpp:282
void stop()
Stops RTI Recording Service.
Definition: Service.hpp:199
CommandReply & execute_command(CommandReply &reply, const CommandRequest &request)
Executes an Administration command on this service.
Definition: Service.hpp:271
Service(const ServiceProperty &property, const HookFunc &shutdown_hook)
Creates a RTI Recording Service instance.
Definition: Service.hpp:164
CommandReply execute_command(const CommandRequest &request)
Executes an Administration command on this service.
Definition: Service.hpp:254
Service(const ServiceProperty &property)
Creates a RTI Recording Service instance.
Definition: Service.hpp:106
The RTI namespace.
Definition: RecordingServiceImpl.hpp:22