Claw  1.7.3
tweener_group.cpp
Go to the documentation of this file.
1 /*
2  CLAW - a C++ Library Absolutely Wonderful
3 
4  CLAW is a free library without any particular aim but being useful to
5  anyone.
6 
7  Copyright (C) 2005-2011 Julien Jorge
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  contact: julien.jorge@gamned.org
23 */
30 
31 /*----------------------------------------------------------------------------*/
37 {
38  m_tweeners.push_back(t);
39 } // tweener_group::insert()
40 
41 /*----------------------------------------------------------------------------*/
46 {
47  m_tweeners.clear();
48 } // tweener_group::clear()
49 
50 /*----------------------------------------------------------------------------*/
54 claw::tween::tweener_group* claw::tween::tweener_group::do_clone() const
55 {
56  return new tweener_group(*this);
57 } // tweener_group::do_clone()
58 
59 /*----------------------------------------------------------------------------*/
63 bool claw::tween::tweener_group::do_is_finished() const
64 {
65  return m_tweeners.empty();
66 } // tweener_group::do_is_finished()
67 
68 /*----------------------------------------------------------------------------*/
73 double claw::tween::tweener_group::do_update( double dt )
74 {
75  typedef std::list<tweener>::iterator iterator_type;
76  double result(dt);
77 
78  iterator_type it = m_tweeners.begin();
79 
80  while ( it != m_tweeners.end() )
81  {
82  const double r = it->update(dt);
83  result = std::min(result, r);
84 
85  if ( it->is_finished() )
86  {
87  const iterator_type tmp(it);
88  ++it;
89  m_tweeners.erase(tmp);
90  }
91  else
92  ++it;
93  }
94 
95  return result;
96 } // tweener_group::do_update()
97 
98 /*----------------------------------------------------------------------------*/
103 {
104  return m_tweeners.empty();
105 } // tweener_group::empty()