qa_time.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <utils/time/clock.h>
00025 #include <utils/time/watch.h>
00026
00027 #include <unistd.h>
00028
00029 #include <iostream>
00030
00031 using namespace std;
00032 using namespace fawkes;
00033
00034 int main(int argc, char** argv)
00035 {
00036 Clock *clock = Clock::instance();
00037
00038 Watch watch(clock);
00039 Time time(clock);
00040
00041 time = watch.clock_time();
00042 cout << "Current clock time is " << time.str() << endl;
00043
00044 watch.start(&time);
00045 cout << "Starting watch at " << time.str() << endl;
00046 sleep(1);
00047
00048 cout << "Watch is running for " << watch.watch_time().str() << endl;
00049 sleep(1);
00050
00051 cout << "Watch is running for " << watch.watch_time().str() << endl;
00052 sleep(1);
00053
00054 watch.pause(&time);
00055 cout << "Start pausing at "<< time.str() << endl;
00056 sleep(1);
00057
00058 cout << "Watch is running for " << watch.watch_time().str() << endl;
00059 sleep(1);
00060
00061 cout << "Watch is running for " << watch.watch_time().str() << endl;
00062 sleep(1);
00063
00064 watch.start(&time);
00065 cout << "Resuming at "<< time.str() << endl;
00066 sleep(1);
00067
00068 watch.stop(&time);
00069 cout << "Stopping watch at "<< time.str() << endl;
00070
00071 cout << "Watch is running for " << watch.watch_time().str() << endl;
00072
00073 time = watch.clock_time();
00074 cout << "Current clock time is " << time.str() << endl;
00075
00076 Clock::finalize();
00077
00078 return 0;
00079 }