OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / moflib-1.0 / src / mof / stream / AnimationScheduler.cpp
1 #include "mof/AnimationScheduler.h"
2 #include "mof/ConsoleIO.h"
3
4 typedef std::multimap<mof::AnimationKey , mof::AnimationResource>::iterator MapItr;
5
6 mof::AnimationScheduler::AnimationScheduler(){
7         m_key = 0;
8
9 }
10
11 mof::AnimationScheduler::~AnimationScheduler(){
12
13 }
14
15 void mof::AnimationScheduler::update(){
16         
17         std::pair<MapItr , MapItr> range(m_map.begin() , m_map.upper_bound(m_key));
18         for(MapItr itr = range.first ; itr != range.second ; ++itr){
19                 if(itr->second.get() != NULL && !itr->second->isPlaying())itr->second->start();
20         }
21         
22         m_key++;
23 }
24
25 void mof::AnimationScheduler::add(int index , mof::AnimationResource pAnimation){
26         if(pAnimation.get() != NULL)pAnimation->stop();
27         m_map.insert(std::multimap<mof::AnimationKey , mof::AnimationResource>::value_type(index , pAnimation));
28
29 }
30                 
31 bool mof::AnimationScheduler::isFinalized(){
32         for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){
33                 if(!itr->second->isFinalized())return false;
34         }
35         return true;
36 }
37
38 void mof::AnimationScheduler::clear(){
39         m_key = 0;
40         m_map.clear();
41 }