Gazebo Msgs

API Reference

10.3.1

A factory that generates protobuf message based on a string type. This allows for global registration of messages via static initialization. If you don't need the singleton, consider using MessageFactory instead. More...

#include <gz/msgs.hh>

Public Types

using FactoryFn = MessageFactory::FactoryFn
 Function that returns unique pointer to base message type. More...
 
using FactoryFnCollection = MessageFactory::FactoryFnCollection
 A map of message types as strings to factory functions. More...
 
using MessagePtr = MessageFactory::MessagePtr
 Unique pointer to base message type. More...
 

Public Member Functions

 Factory (const Factory &)=delete
 Deleted copy constructor. More...
 
 Factory (Factory &&)=delete
 Deleted move constructor. More...
 
void operator= (const Factory &)=delete
 Deleted copy assignment. More...
 
void operator= (Factory &&)=delete
 Deleted move assignment. More...
 

Static Public Member Functions

static MessageFactoryInstance ()
 Get the global MessageFactory instance. More...
 
static void LoadDescriptors (const std::string &_paths)
 Load a collection of descriptor .desc files. More...
 
template<typename T >
static std::unique_ptr< T > New (const std::string &_msgType)
 Create a new instance of a message. More...
 
static MessagePtr New (const std::string &_msgType)
 Create a new instance of a message. More...
 
template<typename T >
static std::unique_ptr< T > New (const std::string &_msgType, const std::string &_args)
 Create a new instance of a message. More...
 
static MessagePtr New (const std::string &_msgType, const std::string &_args)
 Create a new instance of a message. More...
 
static void Register (const std::string &_msgType, FactoryFn _factoryfn)
 Register a message. More...
 
static void Types (std::vector< std::string > &_types)
 Get all the message types. More...
 

Detailed Description

A factory that generates protobuf message based on a string type. This allows for global registration of messages via static initialization. If you don't need the singleton, consider using MessageFactory instead.

Member Typedef Documentation

◆ FactoryFn

Function that returns unique pointer to base message type.

◆ FactoryFnCollection

A map of message types as strings to factory functions.

◆ MessagePtr

Unique pointer to base message type.

Constructor & Destructor Documentation

◆ Factory() [1/2]

Factory ( const Factory )
delete

Deleted copy constructor.

◆ Factory() [2/2]

Factory ( Factory &&  )
delete

Deleted move constructor.

Member Function Documentation

◆ Instance()

static MessageFactory& Instance ( )
static

Get the global MessageFactory instance.

Returns
Reference to the global MessageFactory instance

Referenced by Factory::New().

◆ LoadDescriptors()

static void LoadDescriptors ( const std::string _paths)
static

Load a collection of descriptor .desc files.

Parameters
[in]_pathsA set of directories containing .desc decriptor files. Each directory should be separated by ":".

◆ New() [1/4]

static std::unique_ptr<T> New ( const std::string _msgType)
inlinestatic

Create a new instance of a message.

Parameters
[in]_msgTypeType of message to create.
Returns
Pointer to a google protobuf message. Null if the message type could not be handled.

References Factory::Instance(), and MessageFactory::New().

◆ New() [2/4]

static MessagePtr New ( const std::string _msgType)
static

Create a new instance of a message.

Parameters
[in]_msgTypeType of message to create.
Returns
Pointer to a google protobuf message. Null if the message type could not be handled.

◆ New() [3/4]

static std::unique_ptr<T> New ( const std::string _msgType,
const std::string _args 
)
inlinestatic

Create a new instance of a message.

Parameters
[in]_msgTypeType of message to create.
[in]_argsMessage arguments. This will populate the message.
Returns
Pointer to a google protobuf message. Null if the message type could not be handled.

References Factory::Instance(), and MessageFactory::New().

◆ New() [4/4]

static MessagePtr New ( const std::string _msgType,
const std::string _args 
)
static

Create a new instance of a message.

Parameters
[in]_msgTypeType of message to create.
[in]_argsMessage arguments. This will populate the message.
Returns
Pointer to a google protobuf message. Null if the message type could not be handled.

◆ operator=() [1/2]

void operator= ( const Factory )
delete

Deleted copy assignment.

◆ operator=() [2/2]

void operator= ( Factory &&  )
delete

Deleted move assignment.

◆ Register()

static void Register ( const std::string _msgType,
FactoryFn  _factoryfn 
)
static

Register a message.

Parameters
[in]_msgTypeType of message to register.
[in]_factoryfnFunction that generates the message.

◆ Types()

static void Types ( std::vector< std::string > &  _types)
static

Get all the message types.

Parameters
[out]_typesVector of strings of the message types.

The documentation for this class was generated from the following file: