Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_systems
DVarSystem
DVarSystem.cpp
Go to the documentation of this file.
1
#include "
DVarSystem.hpp
"
2
3
namespace
iv
4
{
5
6
DVarSystem::DVarSystem
(
SystemContainer
* sc ) :
7
System
( sc )
8
{
9
}
10
11
DVarSystem::~DVarSystem
()
12
{
13
for
(
auto
& p_var : this->vars )
14
if
( p_var.second.val )
15
p_var.second.deleter();
16
}
17
18
void
DVarSystem::add_listener
(
DVarListenerI
* listener,
DVarId
id
)
19
{
20
this->vars[ id ].listeners.insert( listener );
21
}
22
23
void
DVarSystem::remove_listener
(
DVarListenerI
* listener,
DVarId
id
)
24
{
25
this->vars[ id ].listeners.erase( listener );
26
}
27
28
29
void
DVarSystem::lock
(
Instance
* setter,
DVarId
id
)
30
{
31
this->vars[ id ].locked = setter;
32
}
33
34
void
DVarSystem::unlock
(
Instance
* setter,
DVarId
id
)
35
{
36
auto
& var = this->vars[ id ];
37
if
( var.locked == setter )
38
var.locked =
nullptr
;
39
else
40
this->
warning
(
SRC_INFO
,
"Can not unlock DVar "
,
id
,
". It is locked to different instance."
);
41
}
42
43
Instance
*
DVarSystem::locked
(
DVarId
id
)
44
{
45
return
this->vars[ id ].locked;
46
}
47
48
}