Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_systems
DVarSystem
DVarProperty.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
DVarId.hpp
"
4
#include <
ivorium_core/ivorium_core.hpp
>
5
#include <optional>
6
#include <functional>
7
8
namespace
iv
9
{
10
11
template
<
class
T >
12
class
DVarProperty
:
private
DVarListenerI
13
{
14
public
:
15
ClientMarker
cm
;
16
17
DVarProperty
(
Instance
* inst,
DVarIdT< T >
id
);
18
~DVarProperty
();
19
22
Instance
*
instance
();
23
28
void
value
( std::optional< T >
const
& val );
29
34
T
value
();
35
41
void
on_changed
( std::function<
void
( T
const
& newval ) >
const
&,
bool
call_immediately =
false
);
42
43
private
:
44
virtual
void
on_dvar_changed(
DVarId
id
, std::type_index type,
void
*
value
)
override
;
45
46
private
:
47
Instance
* inst;
48
DVarSystem
* dvs;
49
DVarIdT< T >
_dvar_id;
50
std::function< void( T
const
& newval ) > _on_changed;
51
std::optional< T > _explicit_value;
52
T _cached_value;
53
54
};
55
56
}
57
58
#include "
DVarProperty.inl
"