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

Manages a single value. More...

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

Public Member Functions

 Value (T value={}) noexcept
 
 operator T () const
 Get the current value. More...
 
Value< T > & operator= (T value)
 Assign new value. More...
 
value () const
 Get the current value. More...
 
bool value (T value)
 Set value. More...
 
- 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. More...
 
void invoke_handlers (Event &event)
 Invoke all handlers with the specified event. More...
 
void invoke_handlers (EventId event)
 Invoke all handlers with the specified EventId. More...
 
EGT_NODISCARD const std::string & name () const
 Get the name of the Object. More...
 
void name (const std::string &name)
 Set the name of the Object. More...
 
RegisterHandle on_event (const EventCallback &handler, const FilterFlags &mask={})
 Add an event handler to be called when the widget generates an event. More...
 
Objectoperator= (const Object &)=delete
 
Objectoperator= (Object &&)=default
 
void remove_handler (RegisterHandle handle)
 Remove an event handler. More...
 

Public Attributes

Signal on_value_changed
 Event signal. More...
 

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

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

Manages a single value.

Constructor & Destructor Documentation

◆ Value()

Value ( value = {})
inlineexplicitnoexcept
Parameters
[in]valueCurrent value.

Member Function Documentation

◆ operator T()

operator T ( ) const
inlineexplicit

Get the current value.

◆ operator=()

Value<T>& operator= ( value)
inline

Assign new value.

◆ value() [1/2]

T value ( ) const
inline

Get the current value.

◆ value() [2/2]

bool value ( value)
inline

Set value.

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

Member Data Documentation

◆ m_value

T m_value {}
protected

The current value.

◆ on_value_changed

Signal on_value_changed

Event signal.

Invoked when the value changes.