|
libpsynth 0.2.1
|
00001 00011 /* 00012 * Copyright (C) 2007 Juan Pedro BolĂvar Puente 00013 * 00014 * This file is part of Psychosynth. 00015 * 00016 * Psychosynth is free software: you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License as published by 00018 * the Free Software Foundation, either version 3 of the License, or 00019 * (at your option) any later version. 00020 * 00021 * Psychosynth is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU General Public License 00027 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00028 * 00029 */ 00030 00031 #ifndef PSYNTH_TIMER_H 00032 #define PSYNTH_TIMER_H 00033 00034 #include <ctime> 00035 00036 namespace psynth 00037 { 00038 namespace base 00039 { 00040 00044 class timer 00045 { 00046 public: 00047 typedef int tick_type; 00048 typedef size_t frame_type; 00049 00051 timer (); 00052 00058 timer (int fpsrate); 00059 00061 ~timer(); 00062 00070 void force_fps (int fpsrate); 00071 00075 void reset (); 00076 00080 void update (); 00081 00086 tick_type ticks () 00087 { 00088 return m_time_count; 00089 } 00090 00094 tick_type delta_ticks () 00095 { 00096 return m_delta; 00097 } 00098 00102 frame_type frames () 00103 { 00104 return m_total_frame_count; 00105 } 00106 00107 private: 00108 timeval m_clock_now; 00109 timeval m_clock_start; 00110 00111 frame_type m_frame_count; 00112 frame_type m_total_frame_count; 00113 00114 tick_type m_time_count; 00115 tick_type m_delta; 00116 tick_type m_last_time; 00117 00118 int m_fps; 00119 double m_rate; 00120 00121 void update_ticks (); 00122 }; 00123 00124 } /* namespace base */ 00125 } /* namespace psynth */ 00126 00127 #endif /* PSYNTH_TIMER_H */
1.7.4