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 25 /** 26 Encapsulate a decoded world time instance 27 */ 28 class DateTime 29 { 30 public: DateTime()31 DateTime() : m_valid(false) { } 32 valid()33 bool valid() const { return m_valid; } 34 year()35 unsigned int year() const { return m_year; } month()36 unsigned int month() const { return m_month; } dayOfMonth()37 unsigned int dayOfMonth() const { return m_dayOfMonth; } 38 seconds()39 unsigned int seconds() const { return m_seconds; } minutes()40 unsigned int minutes() const { return m_minutes; } hours()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 secondsPerMinute()64 unsigned int secondsPerMinute() const { return m_secondsPerMinute; } minutesPerHour()65 unsigned int minutesPerHour() const { return m_minutesPerHour; } hoursPerDay()66 unsigned int hoursPerDay() const { return m_hoursPerDay; } 67 68 ///Emitted when the calendar is updated. 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 91