[219] | 1 | #ifndef __XMLIO_CCalendar__ |
---|
| 2 | #define __XMLIO_CCalendar__ |
---|
| 3 | |
---|
[335] | 4 | /// xios headers /// |
---|
[219] | 5 | #include "xmlioserver_spl.hpp" |
---|
| 6 | #include "exception.hpp" |
---|
| 7 | #include "date.hpp" |
---|
| 8 | |
---|
[335] | 9 | namespace xios |
---|
[219] | 10 | { |
---|
| 11 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
| 12 | |
---|
| 13 | typedef enum _monthEnum |
---|
| 14 | { JAN = 1, FEB = 2, MAR = 3, APR = 4 , MAY = 5 , JUN = 6 , |
---|
| 15 | JUL = 7, AUG = 8, SEP = 9, OCT = 10, NOV = 11, DEC = 12 } MonthEnum; |
---|
| 16 | |
---|
| 17 | ///--------------------------------------------------------------- |
---|
| 18 | |
---|
| 19 | class CDate; |
---|
| 20 | |
---|
| 21 | class CCalendar : public CObject |
---|
| 22 | { |
---|
| 23 | /// Typedef /// |
---|
| 24 | typedef CObject SuperClass; |
---|
| 25 | |
---|
| 26 | public : |
---|
| 27 | |
---|
| 28 | /// Destructeur /// |
---|
| 29 | virtual ~CCalendar(void); |
---|
| 30 | |
---|
| 31 | protected : |
---|
| 32 | |
---|
| 33 | /// Constructeurs /// |
---|
| 34 | CCalendar(void); |
---|
[549] | 35 | CCalendar(const StdString& id); |
---|
[532] | 36 | CCalendar(const StdString& id, |
---|
[334] | 37 | int yr, int mth, int d, |
---|
[219] | 38 | int hr = 0, int min = 0, int sec = 0); |
---|
[532] | 39 | CCalendar(const StdString& id, const CDate& startDate); |
---|
| 40 | CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin); |
---|
[334] | 41 | |
---|
[532] | 42 | CCalendar(const CCalendar& calendar); // Not implemented yet. |
---|
| 43 | CCalendar(const CCalendar* const calendar); // Not implemented yet. |
---|
[219] | 44 | |
---|
| 45 | public : |
---|
| 46 | |
---|
| 47 | //------------------------------------------------------------ |
---|
| 48 | |
---|
| 49 | /// Autres /// |
---|
| 50 | virtual StdString toString(void) const; |
---|
[549] | 51 | virtual void fromString(const StdString& str); |
---|
[219] | 52 | |
---|
| 53 | /// Mutateur /// |
---|
[549] | 54 | void setTimeStep(const CDuration& timestep); |
---|
| 55 | void setInitDate(const CDate& initDate); |
---|
| 56 | void setTimeOrigin(const CDate& timeOrigin); |
---|
[219] | 57 | |
---|
| 58 | /// Traitemants /// |
---|
[549] | 59 | CDate& update(int step); |
---|
[219] | 60 | |
---|
| 61 | /// Accesseurs /// |
---|
[549] | 62 | const CDuration& getTimeStep(void) const; |
---|
| 63 | const CDate& getInitDate(void) const; |
---|
| 64 | const CDate& getTimeOrigin(void) const; |
---|
| 65 | CDate& getCurrentDate(void); |
---|
| 66 | |
---|
[219] | 67 | public : |
---|
[549] | 68 | |
---|
[219] | 69 | //------------------------------------------------------------ |
---|
[549] | 70 | virtual int getMonthLength(const CDate& date) const; |
---|
[219] | 71 | |
---|
| 72 | virtual StdString getType(void) const; |
---|
| 73 | |
---|
[549] | 74 | virtual int getYearTotalLength(const CDate& date) const; // Retourne la durée d'une année en seconde. |
---|
[219] | 75 | |
---|
| 76 | virtual int getYearLength (void) const; // Retourne la durée d'une année en mois. |
---|
| 77 | virtual int getDayLength (void) const; // Retourne la durée d'un jour en heures. |
---|
| 78 | virtual int getHourLength (void) const; // Retourne la durée d'une heure en minute. |
---|
| 79 | virtual int getMinuteLength(void) const; // Retourne la durée d'une minute en secondes. |
---|
[549] | 80 | //!< Returns the day length expressed in seconds |
---|
| 81 | virtual int getDayLengthInSeconds(void) const; |
---|
[219] | 82 | |
---|
| 83 | virtual StdString getMonthName(int month_id) const; |
---|
| 84 | |
---|
| 85 | virtual const StdString getMonthShortName(int month_id) const; |
---|
[549] | 86 | void initializeDate(int yr, int mth, int d, int hr = 0, int min = 0, int sec = 0); |
---|
| 87 | void initializeDate(const StdString& dateStr); |
---|
| 88 | void initializeDate(const StdString& dateStr, const StdString& timeOrigin); |
---|
[219] | 89 | |
---|
| 90 | //------------------------------------------------------------ |
---|
| 91 | |
---|
[532] | 92 | protected: |
---|
[549] | 93 | |
---|
[532] | 94 | //!< Associate the dates to the calendar and check their validity |
---|
| 95 | void initializeDate(); |
---|
| 96 | |
---|
| 97 | //------------------------------------------------------------ |
---|
| 98 | |
---|
[219] | 99 | private : |
---|
| 100 | |
---|
| 101 | /// Propriétés privées /// |
---|
[334] | 102 | CDate initDate; |
---|
| 103 | CDate timeOrigin; |
---|
[219] | 104 | CDate currentDate; |
---|
| 105 | CDuration timestep; |
---|
| 106 | |
---|
| 107 | }; // class CCalendar |
---|
| 108 | |
---|
[335] | 109 | } // namespace xios |
---|
[219] | 110 | |
---|
| 111 | #endif // __XMLIO_CCalendar__ |
---|