1.10
Public Member Functions | Protected Attributes | List of all members
Value< T > Class Template Reference

Manages a single value. More...

#include <value.h>

Inheritance diagram for Value< T >:
Inheritance graph
[legend]

Public Member Functions

 Value (T value={}) noexcept
 
 operator T () const
 Get the current value.
 
Value< T > & operator= (T value)
 Assign new value.
 
value () const
 Get the current value.
 
bool value (T value)
 Set value.
 
- Public Member Functions inherited from Object
 Object () noexcept=default
 
 Object (const Object &)=delete
 
 Object (Object &&)=default
 
virtual ~Object () noexcept=default
 
void clear_handlers ()
 Clear all registered event handlers.
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event.
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId.
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object.
 
void name (const std::string &name)
 Set the name of the Object.
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event.
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler.
 

Public Attributes

Signal on_value_changed
 Event signal.
 

Protected Attributes

m_value {}
 The current value.
 
- Protected Attributes inherited from Object
detail::CopyOnWriteAllocate< CallbackArraym_callbacks
 Array of callbacks.
 
RegisterHandle m_handle_counter {0}
 Counter used to generate unique handles for each callback registration.
 
std::string m_name
 A user defined name for the Object.
 

Additional Inherited Members

- Public Types inherited from Object
using EventCallback = std::function< void(Event &event)>
 Event handler callback function.
 
using FilterFlags = FlagsBase< EventId >
 Event handler EventId filter.
 
using RegisterHandle = uint64_t
 Handle type.
 
- Protected Types inherited from Object
using CallbackArray = std::vector< CallbackMeta >
 Helper type for an array of callbacks.
 

Detailed Description

template<class T>
class egt::v1::Value< T >

Manages a single value.

Constructor & Destructor Documentation

◆ Value()

template<class T >
Value ( value = {})
inlineexplicitnoexcept
Parameters
[in]valueCurrent value.

Member Function Documentation

◆ operator T()

template<class T >
operator T ( ) const
inlineexplicit

Get the current value.

◆ operator=()

template<class T >
Value< T > & operator= ( value)
inline

Assign new value.

◆ value() [1/2]

template<class T >
T value ( ) const
inline

Get the current value.

◆ value() [2/2]

template<class T >
bool value ( value)
inline

Set value.

Parameters
[in]valueValue to set.
Returns
true if changed.

Member Data Documentation

◆ m_value

template<class T >
T m_value {}
protected

The current value.

◆ on_value_changed

template<class T >
Signal on_value_changed

Event signal.

Invoked when the value changes.