Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9658 in orxonox.OLD for trunk


Ignore:
Timestamp:
Aug 7, 2006, 4:23:45 PM (18 years ago)
Author:
bensch
Message:

new smooth-allocator class, this is also a test, to see, if my template experience is good enough for the C++ generic Template Programming Lecture

Location:
trunk/src/lib/util
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/smooth.h

    r9657 r9658  
    11
    22/*!
    3  * @file timer.h
    4  * @brief Definition of Time Class.
    5  *
    6  * These are mainly Classes, that are used for wrapping around SDL_thread
     3 * @file smooth.h
     4 * @brief Definition of Smooth Class.
    75 */
    86
    9 #ifndef __TIMER_H__
    10 #define __TIMER_H__
     7#ifndef __SMOOTH_H__
     8#define __SMOOTH_H__
    119
    12 //! A class to handle time itself
    13 class Timer
     10namespace VariableHandler
    1411{
    15 public:
    16   static double getNow();
    1712
    1813
    19 };
     14  template <typename var_type = float> class LinearIteration
     15  {
     16    public:
     17      static void step(var_type* current, const var_type& fromValue, const var_type& toValue, float stepping);
     18      static bool reached(const var_type& current, const var_type& toValue) const;
     19  };
    2020
    21 #endif /* __TIMER_H__ */
     21
     22  //! A class to handle smoothness of Variables.
     23  /** With this smoothing can be achived for many different types of variables.
     24   */
     25  template <typename var_type = float, class iteration_type = LinearIteration<var_type> > class Smooth
     26  {
     27    public:
     28      Smooth();
     29
     30      const var_type& from() const { return _from; }
     31      const var_type& current() const { return _current; };
     32      const var_type& to() const { return _to; }
     33
     34      inline void tick(float dt) { if (!iteration_type::reached(_current, _to)) iteration_type::step(&_current, _from, _to, dt); };
     35
     36    private:
     37      var_type     _from;
     38      var_type     _current;
     39      var_type     _to;
     40  };
     41}
     42#endif /* __SMOOTH_H__ */
  • trunk/src/lib/util/timer.cc

    r7919 r9658  
    33 * @brief A Timer class, that handles all about time.
    44 *
    5  * code taken from audiere.
     5 * code borrowed from audiere. http://www.audiere.org
    66 */
    77
     
    4545    return tv.tv_sec + tv.tv_usec / 1000000.0;
    4646}
     47
  • trunk/src/lib/util/timer.h

    r7919 r9658  
    44 * @brief Definition of Time Class.
    55 *
    6  * These are mainly Classes, that are used for wrapping around SDL_thread
     6 * Here is a Class that is for measuring time,
     7 * getting the current time, and stepping through time.
     8 *
     9 * @todo: Implement:
     10 * 1. TimeStep
     11 * 2. ApproxTimer
     12 * 3. Class that handles the time-stepping
     13 * 4. Transformations from one time-coding into another:
     14 * 5. debug of Timer.
    715 */
    816
     
    1422{
    1523public:
     24  Timer();
     25  Timer(int time);
     26
     27  void debug() const;
     28
     29  /// STATIC PUBLIC MEMBERS
    1630  static double getNow();
    1731
     32  private:
     33    double         _lastTime;
     34    double         _timeStep;
    1835
    1936};
Note: See TracChangeset for help on using the changeset viewer.