47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
/**
|
|
This file is a part of our_dick
|
|
Copyright (C) 2020 rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef OUR_DICK_ENGINE_OBSERVABLE_TPP
|
|
#define OUR_DICK_ENGINE_OBSERVABLE_TPP
|
|
|
|
namespace egn{
|
|
|
|
template<typename Event>
|
|
void observable<Event>::notify(const_event_ref e){
|
|
for(auto i = m_observers.begin();i != m_observers.end();++i){
|
|
(*i)->on_notify(e);
|
|
}
|
|
}
|
|
template<typename Event>
|
|
void observable<Event>::add_observer(observer_ref o){
|
|
m_observers.push_back(&o);
|
|
}
|
|
template<typename Event>
|
|
void observable<Event>::remove_observer(observer_ref o){
|
|
for(auto i = m_observers.begin();i != m_observers.end();++i){
|
|
if(*i == &o){
|
|
m_observers.erase(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|