DVarSystem.cpp
Go to the documentation of this file.
1 #include "DVarSystem.hpp"
2 
3 namespace iv
4 {
5 
7  System( sc )
8 {
9 }
10 
12 {
13  for( auto & p_var : this->vars )
14  if( p_var.second.val )
15  p_var.second.deleter();
16 }
17 
19 {
20  this->vars[ id ].listeners.insert( listener );
21 }
22 
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 
44 {
45  return this->vars[ id ].locked;
46 }
47 
48 }