source: XIOS/trunk/src/calendar.hpp @ 532

Last change on this file since 532 was 532, checked in by rlacroix, 9 years ago

Add a new attribute type for dates and use it for the context's start_date and time_origin.

The "xios_date" type should now be used to get/set date attributes through the Fortran interface. This avoids using strings to manipulate dates.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 3.6 KB
Line 
1#ifndef __XMLIO_CCalendar__
2#define __XMLIO_CCalendar__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "exception.hpp"
7#include "date.hpp"
8
9namespace xios
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);
35            CCalendar(const StdString& id) ;
36            CCalendar(const StdString& id,
37                      int yr, int mth, int d,
38                      int hr = 0, int min = 0, int sec = 0);
39            CCalendar(const StdString& id, const CDate& startDate);
40            CCalendar(const StdString& id, const CDate& startDate, const CDate& timeOrigin);
41
42            CCalendar(const CCalendar& calendar);       // Not implemented yet.
43            CCalendar(const CCalendar* const calendar); // Not implemented yet.
44
45         public :
46
47            //------------------------------------------------------------
48
49            /// Autres ///
50            virtual StdString toString(void) const;
51            virtual void fromString(const StdString & str);
52
53            /// Mutateur ///
54            void setTimeStep(const CDuration & duration);
55
56            /// Traitemants ///
57            CDate & update(int step);
58
59            /// Accesseurs ///
60            const CDuration & getTimeStep(void) const;
61            const CDate & getInitDate(void) const;
62            const CDate & getTimeOrigin(void) const;
63             CDate & getCurrentDate(void);
64           
65         public :
66         
67            //------------------------------------------------------------
68            virtual int getMonthLength(const CDate & date) const ;
69
70            virtual StdString getType(void) const;
71
72            virtual int getYearTotalLength(const CDate & date) const ; // Retourne la durée d'une année en seconde.
73
74            virtual int getYearLength  (void) const; // Retourne la durée d'une année en mois.
75            virtual int getDayLength   (void) const; // Retourne la durée d'un jour en heures.
76            virtual int getHourLength  (void) const; // Retourne la durée d'une heure en minute.
77            virtual int getMinuteLength(void) const; // Retourne la durée d'une minute en secondes.
78
79            virtual int getNbSecond(const CDate & date) const;
80            virtual StdString getMonthName(int month_id) const;
81
82            virtual const StdString getMonthShortName(int month_id) const;
83            void initializeDate(int yr, int mth, int d, int hr = 0, int min = 0, int sec = 0) ;
84            void initializeDate(const StdString & dateStr);
85            void initializeDate(const StdString & dateStr, const StdString & timeOrigin);
86
87            //------------------------------------------------------------
88
89         protected:
90           
91            //!< Associate the dates to the calendar and check their validity
92            void initializeDate();
93
94            //------------------------------------------------------------
95
96         private :
97
98            /// Propriétés privées ///
99            CDate initDate;
100            CDate timeOrigin;
101            CDate currentDate;
102            CDuration timestep;
103
104      }; // class CCalendar
105
106} // namespace xios
107
108#endif // __XMLIO_CCalendar__
Note: See TracBrowser for help on using the repository browser.