~ubuntu-branches/ubuntu/wily/aspectc++/wily

« back to all changes in this revision

Viewing changes to AspectC++/examples/ObserverPattern/ClockTimer.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-12-23 10:49:40 UTC
  • Revision ID: james.westby@ubuntu.com-20051223104940-ig4klhoi991zs7km
Tags: upstream-0.99+1.0pre2
ImportĀ upstreamĀ versionĀ 0.99+1.0pre2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef CLOCKTIMER_H
 
2
#define CLOCKTIMER_H
 
3
 
 
4
// include files used to obtain the current system time
 
5
#include <time.h>
 
6
 
 
7
//=========================================================
 
8
// ConcreteSubject class
 
9
//
 
10
// ClockTimer
 
11
//
 
12
// It is a ConcreteSubject class and is a child class of
 
13
// the Subject class.
 
14
//
 
15
// It is a time observer. Whenever member function Tick()
 
16
// is called. It obtains the current system
 
17
// time and store it as a character string. It called
 
18
// the update function for all of its observer objects.
 
19
//
 
20
//=========================================================
 
21
 
 
22
class ClockTimer {
 
23
  // store system time
 
24
  int _hour;
 
25
  int _min;
 
26
  int _sec;
 
27
public:
 
28
  ClockTimer() {
 
29
    // normally we would get the real local system time here
 
30
    _hour = 12;
 
31
    _min  = 58;
 
32
    _sec  = 48;
 
33
  };
 
34
  // get hour (used by observer)
 
35
  int GetHour() const { return _hour; }
 
36
  // get minute (used by observer)
 
37
  int GetMinute() const { return _min; }
 
38
  // get second (used by observer)
 
39
  int GetSecond() const { return _sec; }
 
40
 
 
41
  void Tick();  // obtian system time (change state)
 
42
};
 
43
 
 
44
#endif