// /*-------------------------------------------------------------------*\
// | Concrete Template : Timer_Kernel_1
// \*-------------------------------------------------------------------*/
#ifndef CT_TIMER_KERNEL_1
#define CT_TIMER_KERNEL_1 1
///------------------------------------------------------------------------
/// Global Context --------------------------------------------------------
///------------------------------------------------------------------------
#include "AI/Timer/Kernel.h"
// NOTE: <time.h> uses "select" for something else! This is a pain
// but there isn't much that can be done about it.
#undef select
#include <time.h>
#define select(arg) \
switch (To_int (arg))
///------------------------------------------------------------------------
/// Interface -------------------------------------------------------------
///------------------------------------------------------------------------
concrete_template <
concrete_instance class Rep =
Representation <Integer>
>
class Timer_Kernel_1 :
implements
abstract_instance Timer_Kernel,
encapsulates
concrete_instance Rep
{
private:
rep_field_name (Rep, 0, Integer, msec);
/*!
correspondence
self = self.msec
!*/
local_function_body Integer System_Clock ()
/*!
ensures
System_Clock = SYSTEM_CLOCK
!*/
{
return Integer (
(int) (((double) clock ()) * 1000.0 / CLOCKS_PER_SEC)
);
}
public:
standard_concrete_operations (Timer_Kernel_1);
procedure_body Restart ()
{
self[msec] = System_Clock ();
}
function_body Integer Reading ()
{
return System_Clock () - self[msec];
}
};
#endif // CT_TIMER_KERNEL_1
Last modified: Thu Jan 11 17:05:57 EST 2007