Fawkes API Fawkes Development Version
qa_time.cpp
1
2/***************************************************************************
3 * qa_time.cpp - QA app for watch, clock, timesoure, ...
4 *
5 * Generated: Sun June 03 22:33:22 2007
6 * Copyright 2007 Daniel Beck
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#include <utils/time/clock.h>
25#include <utils/time/watch.h>
26
27#include <iostream>
28#include <unistd.h>
29
30using namespace std;
31using namespace fawkes;
32
33int
34main(int argc, char **argv)
35{
36 Clock *clock = Clock::instance();
37
38 Watch watch(clock);
39 Time time(clock);
40
41 time = watch.clock_time();
42 cout << "Current clock time is " << time.str() << endl;
43
44 watch.start(&time);
45 cout << "Starting watch at " << time.str() << endl;
46 sleep(1);
47
48 cout << "Watch is running for " << watch.watch_time().str() << endl;
49 sleep(1);
50
51 cout << "Watch is running for " << watch.watch_time().str() << endl;
52 sleep(1);
53
54 watch.pause(&time);
55 cout << "Start pausing at " << time.str() << endl;
56 sleep(1);
57
58 cout << "Watch is running for " << watch.watch_time().str() << endl;
59 sleep(1);
60
61 cout << "Watch is running for " << watch.watch_time().str() << endl;
62 sleep(1);
63
64 watch.start(&time);
65 cout << "Resuming at " << time.str() << endl;
66 sleep(1);
67
68 watch.stop(&time);
69 cout << "Stopping watch at " << time.str() << endl;
70
71 cout << "Watch is running for " << watch.watch_time().str() << endl;
72
73 time = watch.clock_time();
74 cout << "Current clock time is " << time.str() << endl;
75
76 Clock::finalize();
77
78 return 0;
79}
This is supposed to be the central clock in Fawkes.
Definition: clock.h:35
A class for handling time.
Definition: time.h:93
This is a stop-watch.
Definition: watch.h:32
Fawkes library namespace.