RTI Connext Modern C++ API  Version 5.3.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
 
void reset ()
 After calling this function, this optional_value is not set.
 
const T & get () const
 
T & get ()
 

Detailed Description

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

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

Note: this class is similar to dds::core::optional. They are different due to implementation details. dds::core::optional is only used in IDL-generated types. 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.

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 >::get ( ) const
inline

Get the value.

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

Get the value.

Exceptions
dds::core::PreconditionNotMetErrorif !is_set

RTI Connext Modern C++ API Version 5.3.1 Copyright © Mon Feb 19 2018 Real-Time Innovations, Inc