RTI Connext Modern C++ API  Version 6.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::core::optional_value< T > Class Template Reference

<<extension>> Represents a value that can be initialized or not More...

#include <OptionalValue.hpp>

Public Member Functions

 optional_value ()
 Creates an uninitialized value.
 
 optional_value (const T &value)
 Creates an instance with a value.
 
 optional_value (bool condition, const T &value)
 Conditionally creates an instance that can be uninitialized or initialized with a value.
 
 optional_value (const optional_value< T > &other)
 Copy constructor.
 
bool is_set () const OMG_NOEXCEPT
 
bool has_value () const OMG_NOEXCEPT
 
 operator bool () const OMG_NOEXCEPT
 
void reset ()
 After calling this function, this optional_value is not set.
 
const T & value () const
 Retrieves the underlying object if it exists.
 
T & value ()
 Retrieves the underlying object if it exists.
 
const T & get () const
 Retrieves the underlying object if it exists.
 
T & get ()
 Retrieves the underlying object if it exists.
 
const T & operator* () const
 
T & operator* ()
 
const T * operator-> () const
 
T * operator-> ()
 

Detailed Description

template<typename T>
class rti::core::optional_value< T >

<<extension>> Represents a value that can be initialized or not

This class is similar to dds::core::optional and std::optional.

They have different implementations. dds::core::optional is only used in IDL-generated types, while rti::core::optional_value is used in parts of the API.

Constructor & Destructor Documentation

template<typename T>
rti::core::optional_value< T >::optional_value ( )
inline

Creates an uninitialized value.

template<typename T>
rti::core::optional_value< T >::optional_value ( const T &  value)
inline

Creates an instance with a value.

template<typename T>
rti::core::optional_value< T >::optional_value ( bool  condition,
const T &  value 
)
inline

Conditionally creates an instance that can be uninitialized or initialized with a value.

Parameters
conditionIf it is true it assigns value, otherwise this optional_value is uninitialized
valueThe value to use if condition is true.
template<typename T>
rti::core::optional_value< T >::optional_value ( const optional_value< T > &  other)
inline

Copy constructor.

This optional_value will be initialized only if other is initialized.

Member Function Documentation

template<typename T>
bool rti::core::optional_value< T >::is_set ( ) const
inline

Returns true only if the value is initialized.

[DEPRECATED] Use has_value()

template<typename T>
bool rti::core::optional_value< T >::has_value ( ) const
inline

Returns true only if the value is initialized.

template<typename T>
rti::core::optional_value< T >::operator bool ( ) const
inline

Returns true only if the value is initialized.

template<typename T>
void rti::core::optional_value< T >::reset ( )
inline

After calling this function, this optional_value is not set.

template<typename T>
const T& rti::core::optional_value< T >::value ( ) const
inline

Retrieves the underlying object if it exists.

This operation, unlike operator* throws an exception if the underlying object doesn't exist.

Exceptions
dds::core::PreconditionNotMetErrorif !has_value().
template<typename T>
T& rti::core::optional_value< T >::value ( )
inline

Retrieves the underlying object if it exists.

This operation, unlike operator* throws an exception if the underlying object doesn't exist.

Exceptions
dds::core::PreconditionNotMetErrorif !has_value().
template<typename T>
const T& rti::core::optional_value< T >::get ( ) const
inline

Retrieves the underlying object if it exists.

[DEPRECATED] Use value() or operator*

Exceptions
dds::core::PreconditionNotMetErrorif !has_value().
template<typename T>
T& rti::core::optional_value< T >::get ( )
inline

Retrieves the underlying object if it exists.

[DEPRECATED] Use value() or operator*

Exceptions
dds::core::PreconditionNotMetErrorif !has_value().
template<typename T>
const T& rti::core::optional_value< T >::operator* ( ) const
inline

Get the value, without checking if it exists

Precondition
has_value(), otherwise this operation has undefined behavior. See value().
template<typename T>
T& rti::core::optional_value< T >::operator* ( )
inline

Get the value, without checking if it exists

Precondition
has_value(), otherwise this operation has undefined behavior. See value().
template<typename T>
const T* rti::core::optional_value< T >::operator-> ( ) const
inline

Get the value.

Exceptions
dds::core::PreconditionNotMetErrorif !has_value()
template<typename T>
T* rti::core::optional_value< T >::operator-> ( )
inline

Get the value.

Exceptions
dds::core::PreconditionNotMetErrorif !has_value()

RTI Connext Modern C++ API Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc