00001 #ifndef ERIS_CALENDAR_H
00002 #define ERIS_CALENDAR_H
00003
00004 #include <sigc++/trackable.h>
00005 #include <sigc++/connection.h>
00006
00007 #include <map>
00008 #include <string>
00009
00010 namespace Atlas
00011 {
00012 namespace Message
00013 {
00014 class Element;
00015 typedef std::map<std::string, Element> MapType;
00016 }
00017 }
00018
00019 namespace Eris
00020 {
00021
00022 class Avatar;
00023 class Calendar;
00024
00028 class DateTime
00029 {
00030 public:
00031 DateTime() : m_valid(false) { }
00032
00033 bool valid() const { return m_valid; }
00034
00035 unsigned int year() const { return m_year; }
00036 unsigned int month() const { return m_month; }
00037 unsigned int dayOfMonth() const { return m_dayOfMonth; }
00038
00039 unsigned int seconds() const { return m_seconds; }
00040 unsigned int minutes() const { return m_minutes; }
00041 unsigned int hours() const { return m_hours; }
00042
00043 private:
00044 friend class Calendar;
00045
00046 unsigned int m_year,
00047 m_month,
00048 m_dayOfMonth;
00049
00050 unsigned int m_seconds,
00051 m_minutes,
00052 m_hours;
00053
00054 bool m_valid;
00055 };
00056
00057 class Calendar : public sigc::trackable
00058 {
00059 public:
00060 Calendar(Avatar*);
00061
00062 DateTime now() const;
00063
00064 unsigned int secondsPerMinute() const { return m_secondsPerMinute; }
00065 unsigned int minutesPerHour() const { return m_minutesPerHour; }
00066 unsigned int hoursPerDay() const { return m_hoursPerDay; }
00067
00068 protected:
00069 void topLevelEntityChanged();
00070 void calendarAttrChanged(const Atlas::Message::Element& value);
00071
00072 void initFromCalendarAttr(const Atlas::Message::MapType& cal);
00073
00074 Avatar* m_avatar;
00075
00076 unsigned int m_daysPerMonth,
00077 m_monthsPerYear,
00078 m_hoursPerDay,
00079 m_minutesPerHour,
00080 m_secondsPerMinute;
00081
00082 sigc::connection m_calendarObserver;
00083 };
00084
00085 }
00086
00087 #endif