RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy Class Referencefinal

Interface class to an underlying metadata value. More...

#include <repositoryIf.hpp>

Public Member Functions

 ValueProxy ()=delete
 
 ValueProxy (const ValueProxy &rhs)=default
 
 ValueProxy (ValueProxy &&rhs)=default
 
 ~ValueProxy ()=default
 
bool HasValue () const noexcept
 Check if a value was assigned to the metadata value.
 
const std::type_info & GetValueType () const noexcept
 Get the type of the metadata value stored.
 
 operator const std::any & () const
 Cast operator to return a read-only reference to the underling std::any value object.
 
template<typename T >
T & Cast ()
 Cast the value to the given C++ type.
 
template<typename T >
const T & Cast () const
 Cast the value to the given C++ type.
 
ValueProxyoperator= (const ValueProxy &rhs)
 Assign a new value to this object from an existing metadata value.
 
template<typename T >
ValueProxyoperator= (T &&rhs)
 Assign a new value to this object.
 
void Reset () noexcept
 Delete the value assigned to this metadata value.
 
template<typename T >
RepositoryIf::MetaData::ValueProxyoperator= (T &&rhs)
 

Detailed Description

Interface class to an underlying metadata value.

This class enforces the type checks required by MetaData to make sure only the correct types are allowed in the underling metadata mapping.

Constructor & Destructor Documentation

◆ ValueProxy() [1/3]

◆ ValueProxy() [2/3]

◆ ValueProxy() [3/3]

◆ ~ValueProxy()

rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::~ValueProxy ( )
default

Member Function Documentation

◆ Cast() [1/2]

template<typename T >
T & rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::Cast ( )

Cast the value to the given C++ type.

Warning
This method should only be called if HasValue returns true.
Template Parameters
TThe type to cast the value to.
Returns
A mutable reference to the metadata value.
Exceptions
std::bad_any_castIf the metadata cannot be cast to the given type T.

◆ Cast() [2/2]

template<typename T >
const T & rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::Cast ( ) const

Cast the value to the given C++ type.

Warning
This method should only be called if HasValue returns true.
Template Parameters
TThe type to cast the value to.
Returns
A read-only reference to the metadata value.
Exceptions
std::bad_any_castIf the metadata cannot be cast to the given type T.

◆ GetValueType()

const std::type_info & rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::GetValueType ( ) const
noexcept

Get the type of the metadata value stored.

Returns
The typeid of the C++ object type stored in the value.

◆ HasValue()

bool rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::HasValue ( ) const
inlinenoexcept

Check if a value was assigned to the metadata value.

Returns
true if the value referred to by this proxy object actually has a value assigned and false if it does not.

◆ operator const std::any &()

rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::operator const std::any & ( ) const
inline

Cast operator to return a read-only reference to the underling std::any value object.

◆ operator=() [1/3]

RepositoryIf::MetaData::ValueProxy & rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::operator= ( const ValueProxy & rhs)

Assign a new value to this object from an existing metadata value.

Parameters
[in]rhsThe existing metadata value to assign from.
Returns
Reference to this object.
Exceptions
TypeMismatchIf trying to assign a value with the wrong type for a reserved metadata key.

◆ operator=() [2/3]

template<typename T >
ValueProxy & rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::operator= ( T && rhs)

Assign a new value to this object.

Template Parameters
TThe type of the new value being assigned. Can be std::any in which case runtime type checks are performed.
Parameters
[in]rhsThe new value to assign.
Returns
Reference to this object.
Exceptions
UnsupportedTypeIf the type is not supported for metadata values.
TypeMismatchIf trying to assign a value with the wrong type for a reserved metadata key.

◆ operator=() [3/3]

template<typename T >
RepositoryIf::MetaData::ValueProxy & rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::operator= ( T && rhs)

◆ Reset()

void rtctk::componentFramework::RepositoryIf::MetaData::ValueProxy::Reset ( )
inlinenoexcept

Delete the value assigned to this metadata value.

HasValue will return false after calling this method.


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