Class MessageRef
Defined in File reader.h
Class Documentation
-
class MessageRef
Thin interface class that holds the pointer to the message and reconstructs underlying data to the corresponding object type given the Stream type.
Public Functions
-
MessageRef(const OsfBuffer buf, const MetadataStore &meta_provider, const error_handler_t &error_handler)
The only way to create the MessageRef is to point to the corresponding byte buffer of the message in OSF file.
- Parameters:
buf[in] – The buffer to use to make a MessageRef object.
meta_provider[in] – The metadata store that is used in types reconstruction
error_handler[in] – An optional callback that serves as an error handler.
- uint32_t id () const
Get the message stream id.
- Returns:
The message stream id.
-
const OsfBuffer buf() const
Get the OsfBuffer to the underlying data.
- Returns:
The OsfBuffer to the underlying data.
-
std::string to_string() const
Debug string representation.
- Returns:
The string representation of a MessageRef.
-
template<typename Stream>
inline bool is() const Checks whether the message belongs to the specified Stream type.
- Template Parameters:
Stream – The cpp data type to check against.
- Returns:
If the current MessageRef is of type [Stream].
-
bool is(const std::string &type_str) const
Checks whether the message belongs to the specified Strean type.
- Parameters:
type_str[in] – The data type in string form to check against.
- Returns:
If the current MessageRef is of type type_str.
-
template<typename Stream>
inline std::unique_ptr<typename Stream::obj_type> decode_msg() const Reconstructs the underlying data to the class (copies data).
- Template Parameters:
Stream – The type of the target data.
- Returns:
A smart pointer to the new object.
-
template<typename Stream, typename T>
inline std::unique_ptr<typename Stream::obj_type> decode_msg(T &t) const Decodes the message content into a new object using an external context
t.- Template Parameters:
Stream – Type of the target stream.
T – Additional context type required for decoding.
- Parameters:
t – [in] Additional context object passed into the decoder.
- Returns:
Smart pointer to the decoded object of type Stream::obj_type, or nullptr on failure.
-
std::vector<uint8_t> buffer() const
Get the underlying raw message byte vector.
- Returns:
Return the underlying raw message byte vector.
-
bool operator==(const MessageRef &other) const
Check if two MessageRefs are equal.
- Parameters:
other[in] – The other MessageRef to check against.
- Returns:
If the two MessageRefs are equal.
-
bool operator!=(const MessageRef &other) const
Check if two MessageRefs are not equal.
- Parameters:
other[in] – The other MessageRef to check against.
- Returns:
If the two MessageRefs are not equal.
-
const error_handler_t &error_handler() const
Get the error handler associated with this message.
- Returns:
A constant reference to the error handler.
-
MessageRef(const OsfBuffer buf, const MetadataStore &meta_provider, const error_handler_t &error_handler)