Eris  1.4.0
Calendar.h
1 #ifndef ERIS_CALENDAR_H
2 #define ERIS_CALENDAR_H
3 
4 #include <sigc++/trackable.h>
5 #include <sigc++/connection.h>
6 
7 #include <map>
8 #include <string>
9 
10 namespace Atlas
11 {
12 namespace Message
13 {
14 class Element;
15 typedef std::map<std::string, Element> MapType;
16 }
17 }
18 
19 namespace Eris
20 {
21 
22 class Avatar;
23 class Calendar;
24 
28 class DateTime
29 {
30 public:
31  DateTime() : m_valid(false) { }
32 
33  bool valid() const { return m_valid; }
34 
35  unsigned int year() const { return m_year; }
36  unsigned int month() const { return m_month; }
37  unsigned int dayOfMonth() const { return m_dayOfMonth; }
38 
39  unsigned int seconds() const { return m_seconds; }
40  unsigned int minutes() const { return m_minutes; }
41  unsigned int hours() const { return m_hours; }
42 
43 private:
44  friend class Calendar;
45 
46  unsigned int m_year,
47  m_month,
48  m_dayOfMonth;
49 
50  unsigned int m_seconds,
51  m_minutes,
52  m_hours;
53 
54  bool m_valid;
55 };
56 
57 class Calendar : public sigc::trackable
58 {
59 public:
60  Calendar(Avatar*);
61 
62  DateTime now() const;
63 
64  unsigned int secondsPerMinute() const { return m_secondsPerMinute; }
65  unsigned int minutesPerHour() const { return m_minutesPerHour; }
66  unsigned int hoursPerDay() const { return m_hoursPerDay; }
67 
69  sigc::signal<void> Updated;
70 
71 protected:
72  void topLevelEntityChanged();
73  void calendarAttrChanged(const Atlas::Message::Element& value);
74 
75  void initFromCalendarAttr(const Atlas::Message::MapType& cal);
76 
77  Avatar* m_avatar;
78 
79  unsigned int m_daysPerMonth,
80  m_monthsPerYear,
81  m_hoursPerDay,
82  m_minutesPerHour,
83  m_secondsPerMinute;
84 
85  sigc::connection m_calendarObserver;
86 };
87 
88 } // of namespace Eris
89 
90 #endif
Encapsulate a decoded world time instance.
Definition: Calendar.h:28
Every Eris class and type lives inside the Eris namespace; certain utility functions live in the Util...
Definition: Account.cpp:34
sigc::signal< void > Updated
Emitted when the calendar is updated.
Definition: Calendar.h:69
Definition: Calendar.h:57
Definition: BaseConnection.h:18
The player&#39;s avatar representation.
Definition: Avatar.h:34