summaryrefslogtreecommitdiff
path: root/TAO/tests/Xt_Stopwatch/timer.h
blob: 48979fd954bc70ffe7f13bfc6dc1cb2027dbb447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

//=============================================================================
/**
 *  @file   timer.h
 *
 *  @author Bala <bala@cs.wustl.edu>
 */
//=============================================================================


#ifndef TIMER_H
#define TIMER_H

#include "Stopwatch_display.h"


#include <Xm/Xm.h>


class Timer_imp
{
 public:

  /// Constructor
  Timer_imp (XtAppContext &,
             CORBA::Long,
             Stopwatch_display *);

  /// Destructor
  virtual ~Timer_imp ();

  /// Resets, and starts the clock ticking
  void start (void);

  /// Stops the clock
  void stop (void);

  /// Returns time since timer started
  CORBA::Float  elapsed_time (void);

 private:

  /// Static member function used for TimeOut callback.
  static void tick_callback (XtPointer,
                             XtIntervalId *);

  /// Called every interval_ milliseconds
  void tick (void);

  /// Called at each clock tick...
  virtual void report_time (CORBA::Float);

  /// A copy of the stopwatch object
  Stopwatch_display *stopwatch_;

  /// Current number of ticks
  CORBA::Long counter_;

  /// Time in milliseconds between updates
  CORBA::Long interval_;

  /// Identifier of current TimeOut
  XtIntervalId id_;

  /// Required by Xt functions
  XtAppContext app_;
};


#endif /* TIMER_H */