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