HEBI C++ API  3.10.0
hebi::Command::EnumField< T > Class Template Referencefinal

A message field representable by an enum of a given type. More...

#include <command.hpp>

Public Member Functions

 operator bool () const
 Allows casting to a bool to check if the field has a value without directly calling has(). More...
 
bool has () const
 True if (and only if) the field has a value. More...
 
get () const
 If the field has a value, returns that value; otherwise, returns a default. More...
 
void set (T _value)
 Sets the field to a given value. More...
 
void clear ()
 Removes any currently set value for this field. More...
 

Detailed Description

template<typename T>
class hebi::Command::EnumField< T >

A message field representable by an enum of a given type.

Member Function Documentation

◆ operator bool()

template<typename T>
hebi::Command::EnumField< T >::operator bool ( ) const
inlineexplicit

Allows casting to a bool to check if the field has a value without directly calling has().

This can be used as in the following (assuming 'parent' is a parent message, and this field is called 'myField')

Command::EnumField& f = parent.myField();
if (f)
std::cout << "Field has value: " << f.get() << std::endl;
else
std::cout << "Field has no value!" << std::endl;

◆ has()

template<typename T>
bool hebi::Command::EnumField< T >::has ( ) const
inline

True if (and only if) the field has a value.

◆ get()

template<typename T>
T hebi::Command::EnumField< T >::get ( ) const
inline

If the field has a value, returns that value; otherwise, returns a default.

◆ set()

template<typename T>
void hebi::Command::EnumField< T >::set ( _value)
inline

Sets the field to a given value.

◆ clear()

template<typename T>
void hebi::Command::EnumField< T >::clear ( )
inline

Removes any currently set value for this field.


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