NDEVR
API Documentation
ResourceMirror< t_type >

Creates logic that mirrors two resources. More...

Inheritance diagram for ResourceMirror< t_type >:
[legend]
Collaboration diagram for ResourceMirror< t_type >:
[legend]

Public Member Functions

 ResourceMirror (Resource< t_type > &a, Resource< t_type > &b)
 Constructs a ResourceMirror that synchronizes two resources bidirectionally.
virtual ~ResourceMirror ()
 Destructor.
virtual void addInfoParent (const ResourceBase *info) override
 Registers a parent resource that this listener depends on.
virtual void onValueChanged () override
 Called when either mirrored resource changes.
virtual void removeInfoParent (const ResourceBase *info) override
 Removes a parent resource and disconnects this listener.
Public Member Functions inherited from ResourceListener
 ResourceListener ()
 Constructs a default ResourceListener.
virtual ~ResourceListener ()
 Virtual destructor.
void changeValue ()
 Triggers the value changed callback for this listener.
void disable (bool disable)
 Enables or disables this listener.
void disconnectListener ()
 Disconnects this listener from all parent resources it is subscribed to.
uint04 getInfoParentSize () const
 Returns the number of parent resources this listener is subscribed to.

Public Attributes

Resource< t_type > & a
 The first mirrored resource.
Resource< t_type > & b
 The second mirrored resource.
t_type value
 The last known synchronized value, used to detect which resource changed.

Detailed Description

template<class t_type>
class ResourceMirror< t_type >

Creates logic that mirrors two resources.


Meaning changing either resource will modify the other resource.

Definition at line 41 of file ResourceMirror.h.

Constructor & Destructor Documentation

◆ ResourceMirror()

template<class t_type>
ResourceMirror< t_type >::ResourceMirror ( Resource< t_type > & a,
Resource< t_type > & b )
inline

Constructs a ResourceMirror that synchronizes two resources bidirectionally.

Parameters
[in]aThe first resource to mirror.
[in]bThe second resource to mirror. Its value is initially synced from a.

Definition at line 49 of file ResourceMirror.h.

References ResourceListener::ResourceListener(), a, and b.

Member Function Documentation

◆ addInfoParent()

template<class t_type>
virtual void ResourceMirror< t_type >::addInfoParent ( const ResourceBase * info)
inlineoverridevirtual

Registers a parent resource that this listener depends on.

Parameters
[in]infoThe parent resource to add.

Reimplemented from ResourceListener.

Definition at line 67 of file ResourceMirror.h.

References ResourceListener::addInfoParent().

◆ onValueChanged()

template<class t_type>
virtual void ResourceMirror< t_type >::onValueChanged ( )
inlineoverridevirtual

Called when either mirrored resource changes.

Propagates the new value to the other resource to keep them in sync.

Implements ResourceListener.

Definition at line 84 of file ResourceMirror.h.

References a, b, and value.

◆ removeInfoParent()

template<class t_type>
virtual void ResourceMirror< t_type >::removeInfoParent ( const ResourceBase * info)
inlineoverridevirtual

Removes a parent resource and disconnects this listener.

Parameters
[in]infoThe parent resource to remove.

Reimplemented from ResourceListener.

Definition at line 75 of file ResourceMirror.h.

References ResourceListener::disconnectListener(), and ResourceListener::removeInfoParent().


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