3 Timer_imp::Timer_imp (XtAppContext
&app
,
5 Stopwatch_display
*stopwatch
)
6 :stopwatch_ (stopwatch
),
14 Timer_imp::~Timer_imp ()
21 // Reset the elapsed time
24 // If a previous callback is still in effect, remove it
27 XtRemoveTimeOut (this->id_
);
31 // Register a function to be called in interval_ milliseconds
32 this->id_
= XtAppAddTimeOut (this->app_
,
34 &Timer_imp::tick_callback
,
41 // Remove the current timeout function, if any
43 XtRemoveTimeOut (this->id_
);
49 Timer_imp::elapsed_time()
51 return ((CORBA::Float
) counter_
* interval_
/ 1000.0);
55 Timer_imp::tick_callback (XtPointer client_data
,
58 // Get the object pointer and call the corresponding tick function
59 Timer_imp
*obj
= static_cast<Timer_imp
*> (client_data
);
66 // Increment a counter for each tick
69 // Call derived class function to report time
70 this->report_time (this->elapsed_time ());
72 // Reinstall the timeout callback
73 this->id_
= XtAppAddTimeOut (app_
,
75 &Timer_imp::tick_callback
,
80 Timer_imp::report_time (CORBA::Float time
)
82 stopwatch_
->set_time (time
);