libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moTimer.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moTimer.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 
30 *******************************************************************************/
31 
32 #include "moTypes.h"
33 
34 #ifndef __MO_TIMER_H__
35 #define __MO_TIMER_H__
36 
37 
39 
47 
49 
55 LIBMOLDEO_API MOulong moGetTicksAbsolute( bool force_real_absolute=false );
56 
58 
64 LIBMOLDEO_API MOulong moGetTicksAbsoluteStep( long step_interval=0 );
65 
66 LIBMOLDEO_API MOulong moResetTicksAbsoluteStep( long reset_value=0 );
67 
68 
69 
71 
79 };
80 
82 
89 
91 
96 LIBMOLDEO_API void moSetDuration( MOulong p_timecode );
97 
99 
105 
107 
112 
114 
119 
121 
126 
127 
129 
136 
137 
139 
146 
147 
149 
156 
158 
164 
166 
172 
173 
174 
176 
184 
185  friend class moEffectState;
186  public:
188 
191  moTimerAbsolute();
192  moTimerAbsolute( const moTimerAbsolute &src);
193  virtual ~moTimerAbsolute();
194 
196 
197 
198 
200 
204  int LastDuration() const {
205  return duration;
206  }
207 
208 
210 
213  virtual void Start();
214 
216 
219  void Stop() {
220  on = false;
221  pause_on = false;
222  start_tick = 0;
223  start_last = 0;
224  duration = 0;
225  }
226 
228 
231  void Pause() {
232  pause_on = true;
233  }
234 
236 
239  void Continue() {
240  pause_on = false;
241  }
242 
244 
248  bool Started() const {
249  return on;
250  }
251 
253 
257  bool Paused() const {
258  return on && pause_on;
259  }
260 
262 
266  virtual void SetDuration( MOulong p_timecode );
267 
269 
273  virtual long Duration();
274 
275 
276  virtual moTimerState State() const;
277  virtual const moText& StateToStr() {
278 
279  state_str = "unknown";
280 
281  switch(State()) {
283  state_str = "paused";
284  break;
286  state_str = "playing";
287  break;
289  state_str = "stopped";
290  break;
291  }
292  return state_str;
293  }
294 
295 protected:
296  bool on;
297  bool pause_on;
298 
301 
302  long duration;
303 
307 
308 };
309 
310 
312 
322 
323  public:
324 
326 
330  moTimer();
331 
332  moTimer( const moTimer& src );
333  virtual ~moTimer();
334  moTimer& operator=( const moTimer& src);
335 
336 
337 
339 
342  virtual void Start();
343 
345 
349  virtual void SetDuration( MOulong p_timecode );
350 
352 
356  virtual long Duration();
357 
359 
365  void Fix();
366 
368 
372  void SetTimerId( long p_timerid ) {
373  m_TimerId = p_timerid;
374  }
375 
377 
381  long GetTimerId() {
382  return m_TimerId;
383  }
384 
386 
390  void SetObjectId( long p_objectid ) {
391  m_ObjectId = p_objectid;
392  }
393 
395 
399  long GetObjectId() {
400  return m_ObjectId;
401  }
402 
404 
408  void SetRelativeTimer( moTimerAbsolute* p_pRelativeTimer = NULL ) {
409  m_pRelativeTimer = p_pRelativeTimer;
410  }
411 
412 
414 
419  return m_pRelativeTimer;
420  }
421 
422  private:
423  long m_TimerId;
424  long m_ObjectId;
425 
426  moTimerAbsolute* m_pRelativeTimer;
427 };
428 
429 
431 
432 #endif
433 
void SetTimerId(long p_timerid)
Fija el valor del identificador interno del temporizador.
Definition: moTimer.h:372
LIBMOLDEO_API MOulong moResetTicksAbsoluteStep(long reset_value=0)
Definition: moTimer.cpp:28
#define MOulong
Definition: moTypes.h:392
long last_duration
Definition: moTimer.h:304
virtual void SetDuration(MOulong p_timecode)
Fija el valor del reloj del temporizador.
Definition: moTimer.cpp:92
LIBMOLDEO_API MOulong moGetTicksAbsolute(bool force_real_absolute=false)
Devuelve en milisegundos el valor del reloj de Moldeo.
Definition: moTimer.cpp:15
virtual long Duration()
Devuelve el valor del reloj del temporizador.
Definition: moTimer.cpp:81
LIBMOLDEO_API void moPauseTimer()
Pausa el temporizador global.
Definition: moTimer.cpp:116
LIBMOLDEO_API bool moIsTimerPlaying()
Devuelve verdadero si el temporizador global se encuentra corriendo.
Definition: moTimer.cpp:165
moDeclareExportedDynamicArray(moTimer *, moTimers)
moTimerAbsolute & operator=(const moTimerAbsolute &src)
Definition: moTimer.cpp:64
long last_step_interval
Definition: moTimer.h:306
LIBMOLDEO_API void moStopTimer()
Detiene el temporizador global.
Definition: moTimer.cpp:124
moText state_str
Definition: moTimer.h:305
long start_tick
Definition: moTimer.h:299
#define LIBMOLDEO_API
Definition: moTypes.h:180
clase de para manejar textos
Definition: moText.h:75
void Stop()
Detiene el temporizador.
Definition: moTimer.h:219
virtual const moText & StateToStr()
Definition: moTimer.h:277
void SetRelativeTimer(moTimerAbsolute *p_pRelativeTimer=NULL)
Fija un temporizador relativo.
Definition: moTimer.h:408
Parado, Detenido.
Definition: moTimer.h:77
LIBMOLDEO_API bool moIsTimerPaused()
Devuelve verdadero si el temporizador global está en pausa.
Definition: moTimer.cpp:152
moTimerState
Estado del temporizador.
Definition: moTimer.h:75
LIBMOLDEO_API bool moIsTimerStopped()
Devuelve verdadero si el temporizador global está detenido.
Definition: moTimer.cpp:157
int LastDuration() const
Devuelve el último valor del reloj.
Definition: moTimer.h:204
void Pause()
Congela o pausa el temporizador.
Definition: moTimer.h:231
void Continue()
Prosigue el temporizador.
Definition: moTimer.h:239
LIBMOLDEO_API void moContinueTimer()
Continua luego de una pausa el temporizador global.
Definition: moTimer.cpp:120
Corriendo.
Definition: moTimer.h:78
bool Paused() const
Devuelve el estado en pausa del cronómetro.
Definition: moTimer.h:257
long start_last
Definition: moTimer.h:300
virtual void Start()
Inicia el temporizador.
Definition: moTimer.cpp:75
LIBMOLDEO_API MOulong moGetTicks()
Devuelve en milisegundos el valor del reloj de Moldeo.
Definition: moTimer.cpp:138
LIBMOLDEO_API moText moGetTimerStateStr()
Definition: moTimer.cpp:147
LIBMOLDEO_API void moStartTimer()
Inicia el temporizador global.
Definition: moTimer.cpp:112
Clase para el control de un temporizador (relativo) con identificación
Definition: moTimer.h:321
moMatrix3 & operator=(const moMatrix3 &rkM)
bool Started() const
Devuelve el estado del temporizador.
Definition: moTimer.h:248
void SetObjectId(long p_objectid)
Fija el valor del identificador interno del objeto asociado.
Definition: moTimer.h:390
LIBMOLDEO_API moTimerState moGetTimerState()
Devuelve el estado del temporizador global.
Definition: moTimer.cpp:143
long GetTimerId()
Devuelve el valor del identificador interno del temporizador.
Definition: moTimer.h:381
long GetObjectId()
Devuelve el valor del identificador interno del objeto asociado.
Definition: moTimer.h:399
LIBMOLDEO_API MOulong moGetTicksAbsoluteStep(long step_interval=0)
Devuelve en milisegundos el valor del reloj de Moldeo.
Definition: moTimer.cpp:33
LIBMOLDEO_API MOulong moGetDuration()
Devuelve el valor del reloj del temporizador global.
Definition: moTimer.cpp:134
Clase para el control de un temporizador (absoluto)
Definition: moTimer.h:183
moTimerAbsolute * GetRelativeTimer()
Devuelve el puntero al temporizador relativo.
Definition: moTimer.h:418
LIBMOLDEO_API bool moIsTimerStarted()
Devuelve verdadero si el temporizador global se encuentra iniciado.
Definition: moTimer.cpp:161
LIBMOLDEO_API void moSetDuration(MOulong p_timecode)
Fija el valor del reloj del temporizador global.
Definition: moTimer.cpp:128