RTI Recording Service  Version 6.1.1
rti::recording::Service Class Reference

The RTI Recording Service. More...

#include <Service.hpp>

Inherits Reference< RecordingServiceImpl >.

Public Member Functions

 Service (const ServiceProperty &property)
 Creates a RTI Recording Service instance. More...
 
template<typename HookFunc >
 Service (const ServiceProperty &property, const HookFunc &shutdown_hook)
 Creates a RTI Recording Service instance. More...
 
void start ()
 Starts RTI Recording Service. More...
 
void stop ()
 Stops RTI Recording Service. More...
 
CommandReply execute_command (const CommandRequest &request)
 Executes an Administration command on this service. More...
 
CommandReply & execute_command (CommandReply &reply, const CommandRequest &request)
 Executes an Administration command on this service. More...
 

Static Public Member Functions

static void finalize_globals ()
 Finalizes global resources that RTI Recording Service requires to operate. More...
 

Detailed Description

The RTI Recording Service.

Constructor & Destructor Documentation

◆ Service() [1/2]

rti::recording::Service::Service ( const ServiceProperty property)
inlineexplicit

Creates a RTI Recording Service instance.

Parameters
[in]propertyThe property to configure RTI Recording Service instance.

Referenced by Service().

◆ Service() [2/2]

template<typename HookFunc >
rti::recording::Service::Service ( const ServiceProperty property,
const HookFunc &  shutdown_hook 
)
inlineexplicit

Creates a RTI Recording Service instance.

A callable shutdown hook can optionally be provided to handle the shutdown command received through remote administration or upon execution termination in the case of the REPLAY role. Upon reception of this command, RTI Recording Service will notify the installed hook.

The following example shows simple implementation of a shutdown hook that sets a boolean flag to true when invoked:

// Hook implmentation
struct FlagShutdownHook {
public:
FlagShutdownHook(bool& the_flag) : flag(the_flag)
{
flag = false;
}
void operator()() {
the_flag = true;
}
bool& flag;
};
// Instantiate service with hook
bool my_flag;
rti::recording::Service recording_service(
property,
FlagShutdownHook(my_flag));
...
Parameters
[in]propertyThe property to configure RTI Recording Service instance.
[in]shutdown_hookCallable object to handle the shutdown command. The expected type is a void operator()() (C++11 equivalent is std::function<void()>)

References Service().

Member Function Documentation

◆ start()

void rti::recording::Service::start ( )
inline

Starts RTI Recording Service.

This is a non-blocking operation. RTI Recording Service will create its own set of threads to perform its tasks.

◆ stop()

void rti::recording::Service::stop ( )
inline

Stops RTI Recording Service.

This operation will bloc the instance is fully stopped.

◆ execute_command() [1/2]

CommandReply rti::recording::Service::execute_command ( const CommandRequest &  request)
inline

Executes an Administration command on this service.

This operation directly executes the specified request in this service as if it was directly received from an administration requester.

The request can represent any of the available administration operations as documented in the Administration chapter in the user's manual. This operation gives you an alternative way to control the service using the same remote administration interface but allowing you to call the operation directly.

This operation can also throw an exception if an internal error occurs.

Example:

using namespace rti::recording;
using namespace RTI::Service;
using namespace RTI::Service::Admin;
// Instantiate a RecordingService
RecordingService service(...);
// Prepare a request for any command, for example stop the service
CommandRequest request;
request.action(CommandActionKind::UPDATE_ACTION);
request.resource_identifier("/recording_services/MyRecorder");
dds::topic::topic_type_support<EntityState>::to_cdr_buffer(
reinterpret_cast<std::vector<char> &>(request.octet_body()),
EntityState(EntityStateKind::DISABLED));
// Execute and check result
CommandReply reply = service.execute_command(request);
if (reply.retcode().underlying() != CommandReplyRetcode::OK_RETCODE) {
Logger.instance().error(
std::string("Command returned: ") + reply.string_body());
//handle
...
}
Parameters
[in]requestRepresentation of the command to be executed
Returns
The reply with the result of the command execution.

◆ execute_command() [2/2]

CommandReply& rti::recording::Service::execute_command ( CommandReply &  reply,
const CommandRequest &  request 
)
inline

Executes an Administration command on this service.

Similar to execute_command(const CommandRequest& request) except the caller provides the CommandReply object.

Parameters
[out]replyReppresentation of the reply containing the result of the operation
[in]requestRepresentation of the command to be executed
Returns
A reference to the same reply object provided as a parameter

◆ finalize_globals()

static void rti::recording::Service::finalize_globals ( )
inlinestatic

Finalizes global resources that RTI Recording Service requires to operate.

This operation releases resources specific to RTI Recording Service only. RTI Connext global state shall be released separately through the DomainParticipantFactory's finalize_instance().

This operation should be called by your application only upon exit, after all service instances have been deleted. Calling it at a different time may cause the application to crash.

MT Safety:
unsafe. Applications are not allowed to call this operation concurrently
Exceptions
std::exception