Public Types | Public Member Functions | Private Attributes | List of all members
RosMsgParser::Parser Class Reference

#include <ros_parser.hpp>

Public Types

enum  BlobPolicy { STORE_BLOB_AS_COPY, STORE_BLOB_AS_REFERENCE }
 
enum  MaxArrayPolicy : bool { DISCARD_LARGE_ARRAYS = true, KEEP_LARGE_ARRAYS = false }
 
typedef std::function< void(const ROSType &, Span< uint8_t > &)> VisitingCallback
 

Public Member Functions

void applyVisitorToBuffer (const ROSType &msg_type, Span< uint8_t > &buffer, VisitingCallback callback) const
 applyVisitorToBuffer is used to pass a callback that is invoked every time a chunk of memory storing an instance of ROSType = monitored_type is reached. Note that the VisitingCallback can modify the original message, but can NOT change its size. This means that strings and vectors can not be change their length. More...
 
BlobPolicy blobPolicy () const
 
bool deserialize (Span< const uint8_t > buffer, FlatMessage *flat_output, Deserializer *deserializer) const
 deserializeIntoFlatContainer takes a raw buffer of memory and extract information from it. This data is stored in two key/value vectors, FlatMessage::value and FlatMessage::name. It must be noted that the key type is FieldsVector. This type is not particularly user-friendly, but allows a much faster post-processing. More...
 
ROSMessage::Ptr getMessageByType (const ROSType &type) const
 
const std::shared_ptr< MessageSchema > & getSchema () const
 getSchema provides some metadata amout a registered ROSMessage. More...
 
MaxArrayPolicy maxArrayPolicy () const
 
size_t maxArraySize () const
 
 Parser (const std::string &topic_name, const ROSType &msg_type, const std::string &definition)
 
void setBlobPolicy (BlobPolicy policy)
 
void setMaxArrayPolicy (MaxArrayPolicy discard_entire_array, size_t max_array_size)
 
void setWarningsStream (std::ostream *output)
 Change where the warning messages are displayed. More...
 

Private Attributes

std::vector< int > _alias_array_pos
 
BlobPolicy _blob_policy
 
std::unique_ptr< Deserializer_deserializer
 
MaxArrayPolicy _discard_large_array
 
std::shared_ptr< ROSField_dummy_root_field
 
std::vector< std::string > _formatted_string
 
std::ostream * _global_warnings
 
size_t _max_array_size
 
std::shared_ptr< MessageSchema_schema
 
std::vector< int8_t > _substituted
 
std::string _topic_name
 

Detailed Description

Definition at line 51 of file ros_parser.hpp.

Member Typedef Documentation

◆ VisitingCallback

typedef std::function<void(const ROSType&, Span<uint8_t>&)> RosMsgParser::Parser::VisitingCallback

Definition at line 145 of file ros_parser.hpp.

Member Enumeration Documentation

◆ BlobPolicy

Enumerator
STORE_BLOB_AS_COPY 
STORE_BLOB_AS_REFERENCE 

Definition at line 94 of file ros_parser.hpp.

◆ MaxArrayPolicy

Enumerator
DISCARD_LARGE_ARRAYS 
KEEP_LARGE_ARRAYS 

Definition at line 66 of file ros_parser.hpp.

Constructor & Destructor Documentation

◆ Parser()

RosMsgParser::Parser::Parser ( const std::string &  topic_name,
const ROSType msg_type,
const std::string &  definition 
)
Parameters
topic_namename of the topic to be used as node of the StringTree
msg_typemessage type of the topic.
msg_definitiontext obtained by either:

Definition at line 36 of file rosx_introspection/src/ros_parser.cpp.

Member Function Documentation

◆ applyVisitorToBuffer()

void RosMsgParser::Parser::applyVisitorToBuffer ( const ROSType msg_type,
Span< uint8_t > &  buffer,
VisitingCallback  callback 
) const

applyVisitorToBuffer is used to pass a callback that is invoked every time a chunk of memory storing an instance of ROSType = monitored_type is reached. Note that the VisitingCallback can modify the original message, but can NOT change its size. This means that strings and vectors can not be change their length.

Parameters
msg_identifierString ID to identify the registered message (use registerMessageDefinition first).
monitored_typeROSType that triggers the invokation to the callback
bufferOriginal buffer, passed as mutable since it might be modified.
callbackThe callback.

◆ blobPolicy()

BlobPolicy RosMsgParser::Parser::blobPolicy ( ) const
inline

Definition at line 109 of file ros_parser.hpp.

◆ deserialize()

bool RosMsgParser::Parser::deserialize ( Span< const uint8_t >  buffer,
FlatMessage flat_output,
Deserializer deserializer 
) const

deserializeIntoFlatContainer takes a raw buffer of memory and extract information from it. This data is stored in two key/value vectors, FlatMessage::value and FlatMessage::name. It must be noted that the key type is FieldsVector. This type is not particularly user-friendly, but allows a much faster post-processing.

IMPORTANT: this approach is not meant to be used with use arrays such as maps, point clouds and images.For this reason the argument max_array_size is used.

This funtion is almost always followed by CreateRenamedValues, which provide a more human-readable key-value representation.

Parameters
bufferraw memory to be parsed.
flat_outputoutput to store the result. It is recommended to reuse the same object multiple times to avoid memory allocations and speed up the parsing.
Returns
true if the entire message was parsed or false if parts of the message were skipped because an array has (size > max_array_size)

Definition at line 76 of file rosx_introspection/src/ros_parser.cpp.

◆ getMessageByType()

ROSMessage::Ptr RosMsgParser::Parser::getMessageByType ( const ROSType type) const

Definition at line 54 of file rosx_introspection/src/ros_parser.cpp.

◆ getSchema()

const std::shared_ptr< MessageSchema > & RosMsgParser::Parser::getSchema ( ) const

getSchema provides some metadata amout a registered ROSMessage.

Definition at line 49 of file rosx_introspection/src/ros_parser.cpp.

◆ maxArrayPolicy()

MaxArrayPolicy RosMsgParser::Parser::maxArrayPolicy ( ) const
inline

Definition at line 84 of file ros_parser.hpp.

◆ maxArraySize()

size_t RosMsgParser::Parser::maxArraySize ( ) const
inline

Definition at line 89 of file ros_parser.hpp.

◆ setBlobPolicy()

void RosMsgParser::Parser::setBlobPolicy ( BlobPolicy  policy)
inline

Definition at line 104 of file ros_parser.hpp.

◆ setMaxArrayPolicy()

void RosMsgParser::Parser::setMaxArrayPolicy ( MaxArrayPolicy  discard_entire_array,
size_t  max_array_size 
)
inline

Default values are DISCARD_LARGE_ARRAYS and 100. The maximum permissible value of max_array_size is 10.000 (but don't)

Definition at line 74 of file ros_parser.hpp.

◆ setWarningsStream()

void RosMsgParser::Parser::setWarningsStream ( std::ostream *  output)
inline

Change where the warning messages are displayed.

Definition at line 166 of file ros_parser.hpp.

Member Data Documentation

◆ _alias_array_pos

std::vector<int> RosMsgParser::Parser::_alias_array_pos
private

Definition at line 178 of file ros_parser.hpp.

◆ _blob_policy

BlobPolicy RosMsgParser::Parser::_blob_policy
private

Definition at line 183 of file ros_parser.hpp.

◆ _deserializer

std::unique_ptr<Deserializer> RosMsgParser::Parser::_deserializer
private

Definition at line 186 of file ros_parser.hpp.

◆ _discard_large_array

MaxArrayPolicy RosMsgParser::Parser::_discard_large_array
private

Definition at line 181 of file ros_parser.hpp.

◆ _dummy_root_field

std::shared_ptr<ROSField> RosMsgParser::Parser::_dummy_root_field
private

Definition at line 184 of file ros_parser.hpp.

◆ _formatted_string

std::vector<std::string> RosMsgParser::Parser::_formatted_string
private

Definition at line 179 of file ros_parser.hpp.

◆ _global_warnings

std::ostream* RosMsgParser::Parser::_global_warnings
private

Definition at line 174 of file ros_parser.hpp.

◆ _max_array_size

size_t RosMsgParser::Parser::_max_array_size
private

Definition at line 182 of file ros_parser.hpp.

◆ _schema

std::shared_ptr<MessageSchema> RosMsgParser::Parser::_schema
private

Definition at line 172 of file ros_parser.hpp.

◆ _substituted

std::vector<int8_t> RosMsgParser::Parser::_substituted
private

Definition at line 180 of file ros_parser.hpp.

◆ _topic_name

std::string RosMsgParser::Parser::_topic_name
private

Definition at line 176 of file ros_parser.hpp.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:52