ALMaSS Rabbit ODdox  1.00
The rabbit model description following ODdox protocol
calendar.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************************************
3 Copyright (c) 2011, Christopher John Topping, University of Aarhus
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without modification, are permitted provided
7 that the following conditions are met:
8 
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the
10 following disclaimer.
11 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12 the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
17 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
19 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 ********************************************************************************************************
23 */
24 
25 
26 #ifndef CALENDAR_H
27 #define CALENDAR_H
28 
29 extern class Calendar *g_date;
30 
31 struct aDate
32 {
33  int year;
34  int month;
35  int day;
36 };
37 
38 class Calendar
39 {
40 public:
41  // Reset to default values, January 1st, 2000.
42  // This is unused for the moment.
43  void Reset(void);
44 
45  // The return value for the next two methods
46  // indicates wether the global Tick() should be called
47  // for the whole landscape model. Order matters here, so this cannot just
48  // be done internally within the Calendar class.
49  bool TickMinute(void);
50  bool TickMinute10(void);
51  // Resets minute counter to zero.
52  bool TickHour(void);
53 
54  // Advance date by one day. Resets minute and hour counters to zero.
55  void Tick(void);
56 
57  long Date(void) { return m_date; }
58  int DayInYear(void) { return m_day_in_year; }
59  // long DaysInOldYears( void ) { return m_olddays; }
60  long OldDays(void) { return m_olddays; }
61  long GlobalDate(int a_day, int a_month, int a_year);
62 
63  int DayLength(void) { return m_todayslength; }
64  int DayLength(int a_day_in_year);
65  int GetFirstYear(void) { return m_firstyear; }
66  int GetLastYear(void) { return m_lastyear; }
67  int GetYear(void) { return m_year; }
68  int GetYearNumber(void) { return m_simulationyear; }
69  int GetMonth(void) { return m_month + 1; }
70  int GetMinute(void) { return m_minutes; }
71  int GetHour(void) { return m_hours; }
72  int GetDayInMonth(void) { return m_day_in_month; }
73  double GetDaylightProportion(void){ return m_daylightproportion; }
74  bool JanFirst( void ) { return m_janfirst; }
75  bool MarchFirst( void ) { return m_marchfirst; }
76  void SetFirstYear( int a_year ) { m_firstyear = a_year; }
77  void SetLastYear( int a_year ) { m_lastyear = a_year; }
78  bool ValidDate( int a_day, int a_month );
79  // Check the date with ValidDate() before using DayInYear()
80  // (or suffer the consequences).
81  int DayInYear( int a_day, int a_month );
82 
83  Calendar( void );
84 
85  private:
86  long m_date;
87  long m_olddays;
88  int m_firstyear; // Used for resetting the date.
92  int m_month;
93  int m_year;
97  int m_minutes;
98  int m_hours;
99  bool m_janfirst;
101 
102  static int m_daylength[];
103 }; // class Calendar
104 
105 #endif // CALENDAR_H
int m_hours
Definition: calendar.h:98
long Date(void)
Definition: calendar.h:57
long m_olddays
Definition: calendar.h:87
int month
Definition: calendar.h:34
int m_firstyear
Definition: calendar.h:88
int GetYearNumber(void)
Definition: calendar.h:68
int m_lastyear
Definition: calendar.h:89
int m_day_in_month
Definition: calendar.h:90
int m_todayslength
Definition: calendar.h:95
void SetLastYear(int a_year)
Definition: calendar.h:77
Definition: calendar.h:31
long m_date
Definition: calendar.h:86
int GetYear(void)
Definition: calendar.h:67
double m_daylightproportion
Definition: calendar.h:96
int GetFirstYear(void)
Definition: calendar.h:65
int m_year
Definition: calendar.h:93
int GetDayInMonth(void)
Definition: calendar.h:72
int DayInYear(void)
Definition: calendar.h:58
void SetFirstYear(int a_year)
Definition: calendar.h:76
class Calendar * g_date
Definition: calendar.cpp:38
bool m_janfirst
Definition: calendar.h:99
int m_day_in_year
Definition: calendar.h:91
int GetMinute(void)
Definition: calendar.h:70
int day
Definition: calendar.h:35
bool MarchFirst(void)
Definition: calendar.h:75
bool JanFirst(void)
Definition: calendar.h:74
bool m_marchfirst
Definition: calendar.h:100
int m_minutes
Definition: calendar.h:97
int DayLength(void)
Definition: calendar.h:63
int m_month
Definition: calendar.h:92
int m_simulationyear
Definition: calendar.h:94
int GetMonth(void)
Definition: calendar.h:69
double GetDaylightProportion(void)
Definition: calendar.h:73
long OldDays(void)
Definition: calendar.h:60
int GetLastYear(void)
Definition: calendar.h:66
int GetHour(void)
Definition: calendar.h:71
int year
Definition: calendar.h:33