4 Timer_imp::Timer_imp (XtAppContext
&app
,
6 Stopwatch_display
*stopwatch
)
7 :stopwatch_ (stopwatch
),
15 Timer_imp::~Timer_imp ()
20 Timer_imp::start (void)
22 // Reset the elapsed time
25 // If a previous callback is still in effect, remove it
28 XtRemoveTimeOut (this->id_
);
32 // Register a function to be called in interval_ milliseconds
33 this->id_
= XtAppAddTimeOut (this->app_
,
35 &Timer_imp::tick_callback
,
40 Timer_imp::stop (void)
42 // Remove the current timeout function, if any
44 XtRemoveTimeOut (this->id_
);
50 Timer_imp::elapsed_time(void)
52 return ((CORBA::Float
) counter_
* interval_
/ 1000.0 );
56 Timer_imp::tick_callback (XtPointer client_data
,
59 // Get the object pointer and call the corresponding tick function
60 Timer_imp
*obj
= static_cast<Timer_imp
*> (client_data
);
66 Timer_imp::tick (void)
68 // Increment a counter for each tick
71 // Call derived class function to report time
72 this->report_time (this->elapsed_time ());
74 // Reinstall the timeout callback
75 this->id_
= XtAppAddTimeOut (app_
,
77 &Timer_imp::tick_callback
,
82 Timer_imp::report_time (CORBA::Float time
)
84 stopwatch_
->set_time (time
);