1 /** @file observers.cpp
2  *
3  * @authors Copyright (c) 2016-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  *
5  * @par License
6  * LGPL: http://www.gnu.org/licenses/lgpl.html
7  *
8  * <small>This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at your
11  * option) any later version. This program is distributed in the hope that it
12  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
14  * General Public License for more details. You should have received a copy of
15  * the GNU Lesser General Public License along with this program; if not, see:
16  * http://www.gnu.org/licenses</small>
17  */
18 
19 #include "de/Observers"
20 
21 namespace de {
22 
~IAudience()23 IAudience::~IAudience()
24 {}
25 
ObserverBase()26 ObserverBase::ObserverBase()
27 {}
28 
~ObserverBase()29 ObserverBase::~ObserverBase()
30 {
31     DENG2_GUARD(_memberOf);
32     for (IAudience *observers : _memberOf.value)
33     {
34         observers->removeMember(this);
35     }
36 }
37 
addMemberOf(IAudience & observers)38 void ObserverBase::addMemberOf(IAudience &observers)
39 {
40     DENG2_GUARD(_memberOf);
41     _memberOf.value.insert(&observers);
42 }
43 
removeMemberOf(IAudience & observers)44 void ObserverBase::removeMemberOf(IAudience &observers)
45 {
46     DENG2_GUARD(_memberOf);
47     _memberOf.value.remove(&observers);
48 }
49 
50 } // namespace de
51