2009-11-08 Chris Toshok <toshok@ximian.com>
[moon.git] / src / timesource.h
blobeb86a7c343e38ef9eb9229fb8aec94219a9eabe2
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * Contact:
4 * Moonlight List (moonlight-list@lists.ximian.com)
6 * Copyright 2007 Novell, Inc. (http://www.novell.com)
8 * See the LICENSE file included with the distribution for details.
9 *
12 #ifndef MOON_TIMESOURCE_H
13 #define MOON_TIMESOURCE_H
15 #include <glib.h>
16 #include "clock.h"
17 #include "deployment.h"
19 #define MOON_PRIORITY_HIGH G_PRIORITY_DEFAULT
20 #define MOON_PRIORITY_DEFAULT G_PRIORITY_DEFAULT_IDLE
21 #define MOON_PRIORITY_IDLE G_PRIORITY_DEFAULT_IDLE
23 class TimeSource : public EventObject {
24 protected:
25 virtual ~TimeSource ();
27 public:
28 TimeSource ();
29 TimeSource (Deployment *deployment);
31 virtual void Start ();
32 virtual void Stop ();
33 virtual void SetTimerFrequency (int timeout);
35 virtual TimeSpan GetNow ();
37 const static int TickEvent;
40 class SystemTimeSource : public TimeSource {
41 protected:
42 virtual ~SystemTimeSource ();
44 public:
45 SystemTimeSource ();
46 SystemTimeSource (Deployment *deployment);
48 virtual void Start ();
49 virtual void Stop ();
50 virtual void SetTimerFrequency (int timeout);
52 virtual TimeSpan GetNow ();
54 private:
55 guint timeout_id;
56 int frequency;
57 static gboolean tick_timeout (gpointer data);
60 class ManualTimeSource : public TimeSource {
61 protected:
62 virtual ~ManualTimeSource ();
64 public:
65 ManualTimeSource ();
67 virtual TimeSpan GetNow ();
69 void SetCurrentTime (TimeSpan current_time);
71 private:
72 TimeSpan current_time;
75 G_BEGIN_DECLS
77 /* useful for timing things */
78 TimeSpan get_now (void);
80 G_END_DECLS
82 #endif /* MOON_TIMESOURCE_H */