1 #include "mof/EventScheduler.hpp"
2 #include "mof/EventCondition.hpp"
5 #include "mof/utilities.hpp"
8 class TimeEventCondition : public mof::EventCondition{
9 mof::FrameNumber limit;
10 mof::FrameNumber count;
13 TimeEventCondition(mof::FrameNumber limit)
14 : limit(limit) , count(0)
18 virtual ~TimeEventCondition(){}
21 return count == limit;
24 virtual bool isDisposable(){
28 virtual void update(){
29 if(limit >= count)count++;
33 struct mof::EventScheduler::Impl{
34 typedef std::pair<mof::EventCondition* , boost::function0<void>> Schedule;
35 typedef std::list<std::pair<mof::EventCondition* , boost::function0<void>>> EventList;
42 foreach( Impl::Schedule &value , eventList ){
49 mof::EventScheduler::EventScheduler()
54 mof::EventScheduler::~EventScheduler(){
58 void mof::EventScheduler::addEvent( mof::EventCondition* pCondition , const boost::function0<void> &action){
59 m_pImpl->eventList.push_back(std::pair<mof::EventCondition* , boost::function0<void>>(pCondition , action));
62 void mof::EventScheduler::addEvent(mof::FrameNumber frame, const boost::function0<void> &action){
63 addEvent(new TimeEventCondition(frame) , action);
66 void mof::EventScheduler::update(){
67 for( Impl::EventList::iterator itr = m_pImpl->eventList.begin() ;
68 itr != m_pImpl->eventList.end() ;
71 if(itr->first->test()){
74 if(itr->first->isDisposable()){
76 itr = m_pImpl->eventList.erase(itr);