NDEVR
API Documentation
Resource< T >final

A core part of the engine, stores variables that can be listened to with ResourceListener which will recieve updates when changed. More...

Inherits ResourceBase.

Collaboration diagram for Resource< T >:
[legend]

Public Member Functions

 Resource (const Resource< T > &value)=delete
 Copy constructor is deleted to enforce unique ownership.
 Resource (const T &value)
 Constructs a Resource with an initial value.
const T & get () const
 Returns a const reference to the stored value.
void getCopy (T &copy) const
 Copies the stored value into the provided output parameter.
T & getModifiable ()
 Returns a mutable reference to the stored value without notifying listeners.
bool isEqualTo (const T &value) const
 Checks whether the given value is equal to the stored value.
Resource< T > & operator= (const Resource< T > &)=delete
 Copy assignment is deleted to enforce unique ownership.
void set (const T &info, bool check_equal=true)
 Destructor.
void set (T &&info, bool check_equal=true)
 Sets the stored value by move and notifies all listeners.
Public Member Functions inherited from ResourceBase
 ResourceBase ()
 Constructs a default ResourceBase with no listeners.
 ResourceBase (const ResourceBase &value)
 Copy constructs a ResourceBase.
virtual ~ResourceBase ()
 Virtual destructor.
ResourceListeneraddListener (ResourceListener *listener) const
 Adds a listener that will be notified when this resource changes.
void addListener (ResourceListener *listener, bool silent_add) const
 Adds a listener with optional silent registration.
void refreshListeners ()
 Notifies all registered listeners that the resource value has changed.
void removeListener (ResourceListener *listener) const
 Removes a listener so it no longer receives update notifications.

Additional Inherited Members

Protected Attributes inherited from ResourceBase
Buffer< ResourceListener * > m_listeners
 The collection of listeners subscribed to this resource.

Detailed Description

template<class T>
class Resource< T >

A core part of the engine, stores variables that can be listened to with ResourceListener which will recieve updates when changed.


Definition at line 41 of file Resource.h.

Constructor & Destructor Documentation

◆ Resource()

template<class T>
Resource< T >::Resource ( const T & value)
inlineexplicit

Constructs a Resource with an initial value.

Parameters
[in]valueThe initial value to store in the Resource.

Definition at line 48 of file Resource.h.

References ResourceBase::ResourceBase().

Referenced by Resource(), and operator=().

Member Function Documentation

◆ get()

template<class T>
const T & Resource< T >::get ( ) const
inline

Returns a const reference to the stored value.

Returns
A const reference to the current value.

Definition at line 89 of file Resource.h.

Referenced by QCustomLineEdit::setup(), and QCustomComboBox::setupResource().

◆ getCopy()

template<class T>
void Resource< T >::getCopy ( T & copy) const
inline

Copies the stored value into the provided output parameter.

Parameters
[in]copyThe variable to receive a copy of the stored value.

Definition at line 98 of file Resource.h.

◆ getModifiable()

template<class T>
T & Resource< T >::getModifiable ( )
inline

Returns a mutable reference to the stored value without notifying listeners.

Returns
A non-const reference to the current value.

Definition at line 107 of file Resource.h.

◆ isEqualTo()

template<class T>
bool Resource< T >::isEqualTo ( const T & value) const
inline

Checks whether the given value is equal to the stored value.

Parameters
[in]valueThe value to compare against the stored value.
Returns
True if the values are equal, false otherwise.

Definition at line 118 of file Resource.h.

Referenced by set(), and set().

◆ set() [1/2]

template<class T>
void Resource< T >::set ( const T & info,
bool check_equal = true )
inline

Destructor.

Sets the stored value by copy and notifies all listeners.

Parameters
[in]infoThe new value to assign.
[in]check_equalIf true, skips the update when the new value equals the current value.

Definition at line 62 of file Resource.h.

References isEqualTo(), and ResourceBase::refreshListeners().

Referenced by QCustomLineEdit::setup(), and QCustomComboBox::setupResource().

◆ set() [2/2]

template<class T>
void Resource< T >::set ( T && info,
bool check_equal = true )
inline

Sets the stored value by move and notifies all listeners.

Parameters
[in]infoThe new value to move-assign.
[in]check_equalIf true, skips the update when the new value equals the current value.

Definition at line 76 of file Resource.h.

References isEqualTo(), and ResourceBase::refreshListeners().


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