Eris  1.3.21
Calendar.h
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 
00069     sigc::signal<void> Updated;
00070 
00071 protected:
00072     void topLevelEntityChanged();
00073     void calendarAttrChanged(const Atlas::Message::Element& value);
00074 
00075     void initFromCalendarAttr(const Atlas::Message::MapType& cal);
00076 
00077     Avatar* m_avatar;
00078 
00079     unsigned int m_daysPerMonth,
00080                  m_monthsPerYear,
00081                  m_hoursPerDay,
00082                  m_minutesPerHour,
00083                  m_secondsPerMinute;
00084 
00085     sigc::connection m_calendarObserver;
00086 };
00087 
00088 } // of namespace Eris
00089 
00090 #endif