NDEVR
API Documentation
ResourceListener.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: ResourceListener
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Buffer.h>
34#include "DLLInfo.h"
35namespace NDEVR
36{
37 class ResourceListener;
38
42 class NDEVR_BASE_API ResourceBase
43 {
44 public:
49
54 explicit ResourceBase(const ResourceBase& value);
55
59 virtual ~ResourceBase();
60
65 void removeListener(ResourceListener* listener) const;
66
73
79 void addListener(ResourceListener* listener, bool silent_add) const;
80
85 protected:
87 };
88
93 class NDEVR_BASE_API ResourceListener
94 {
95 public:
100
105
110
115
120 virtual void addInfoParent(const ResourceBase* info);
121
126 virtual void removeInfoParent(const ResourceBase* info)
127 {
128 m_parents.removeElement(info);
129 }
130
136 {
137 return m_parents.size();
138 }
139
144 void disable(bool disable)
145 {
146 m_is_active = disable;
147 }
148
153 virtual void onValueChanged() = 0;
154 private:
156 bool m_is_active;
157 };
158};
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A base class for templated resources.
ResourceBase(const ResourceBase &value)
Copy constructs a ResourceBase.
void removeListener(ResourceListener *listener) const
Removes a listener so it no longer receives update notifications.
ResourceBase()
Constructs a default ResourceBase with no listeners.
Buffer< ResourceListener * > m_listeners
The collection of listeners subscribed to this resource.
void addListener(ResourceListener *listener, bool silent_add) const
Adds a listener with optional silent registration.
ResourceListener * addListener(ResourceListener *listener) const
Adds a listener that will be notified when this resource changes.
void refreshListeners()
Notifies all registered listeners that the resource value has changed.
virtual ~ResourceBase()
Virtual destructor.
A class that can subscribe to any number of Resources which will get updates when the Resource(s) hav...
virtual void removeInfoParent(const ResourceBase *info)
Removes a ResourceBase from the list of parents this listener is observing.
ResourceListener()
Constructs a default ResourceListener.
uint04 getInfoParentSize() const
Returns the number of parent resources this listener is subscribed to.
void changeValue()
Triggers the value changed callback for this listener.
void disable(bool disable)
Enables or disables this listener.
virtual void addInfoParent(const ResourceBase *info)
Registers a ResourceBase as a parent that this listener is observing.
virtual ~ResourceListener()
Virtual destructor.
virtual void onValueChanged()=0
Called when a subscribed resource value has changed.
void disconnectListener()
Disconnects this listener from all parent resources it is subscribed to.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...