API Documentation
Loading...
Searching...
No Matches
Resource.h
Go to the documentation of this file.
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: Resource
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/ResourceListener.h>
34namespace NDEVR
35{
36 template<class T>
37 class Resource final : public ResourceBase
38 {
39 public:
40 explicit Resource(const T& value)
41 : ResourceBase()
42 , m_value(value)
43 {}
44
45 Resource(const Resource<T>& value) = delete;
47 virtual ~Resource(){};
48
49 void set(const T& info, bool check_equal = true)
50 {
51 if(check_equal && isEqualTo(info))
52 {
53 return;
54 }
55 m_value = info;
57 }
58 void set(T&& info, bool check_equal = true)
59 {
60 if(check_equal && isEqualTo(info))
61 {
62 return; // Do nothing on same value
63 }
64 std::swap(m_value, info);
66 }
67 const T& get() const
68 {
69 return m_value;
70 }
71
72 void getCopy(T& copy) const
73 {
74 copy = m_value;
75 }
76
78 {
79 return m_value;
80 }
81
82
83 bool isEqualTo(const T& value) const
84 {
85 return value == m_value;
86 }
87
88
89
90 private:
91 T m_value;
92
93 };
94
95
96};
Definition ResourceListener.h:40
void refreshListeners()
Definition ResourceListener.cpp:62
Definition Toggle.h:41
Resource(const Resource< T > &value)=delete
Resource(const T &value)
Definition Resource.h:40
T & getModifiable()
Definition Resource.h:77
const T & get() const
Definition Resource.h:67
virtual ~Resource()
Definition Resource.h:47
bool isEqualTo(const T &value) const
Definition Resource.h:83
void set(T &&info, bool check_equal=true)
Definition Resource.h:58
Resource< T > & operator=(const Resource< T > &)=delete
void getCopy(T &copy) const
Definition Resource.h:72
void set(const T &info, bool check_equal=true)
Definition Resource.h:49
Definition ACIColor.h:37