ALMaSS Rabbit ODdox  1.1
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; }
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
Calendar::m_marchfirst
bool m_marchfirst
Definition: calendar.h:100
Calendar::m_hours
int m_hours
Definition: calendar.h:98
Calendar::m_daylightproportion
double m_daylightproportion
Definition: calendar.h:96
Calendar::GetYear
int GetYear(void)
Definition: calendar.h:67
aDate::month
int month
Definition: calendar.h:34
aDate::year
int year
Definition: calendar.h:33
Calendar::TickHour
bool TickHour(void)
Definition: calendar.cpp:128
Calendar::SetFirstYear
void SetFirstYear(int a_year)
Definition: calendar.h:76
Calendar::GetYearNumber
int GetYearNumber(void)
Definition: calendar.h:68
Calendar::GetHour
int GetHour(void)
Definition: calendar.h:71
Calendar
Definition: calendar.h:38
Calendar::ValidDate
bool ValidDate(int a_day, int a_month)
Definition: calendar.cpp:79
Calendar::GetMonth
int GetMonth(void)
Definition: calendar.h:69
Calendar::GetDayInMonth
int GetDayInMonth(void)
Definition: calendar.h:72
Calendar::m_firstyear
int m_firstyear
Definition: calendar.h:88
Calendar::DayLength
int DayLength(void)
Definition: calendar.h:63
Calendar::m_day_in_year
int m_day_in_year
Definition: calendar.h:91
Calendar::SetLastYear
void SetLastYear(int a_year)
Definition: calendar.h:77
Calendar::Tick
void Tick(void)
Definition: calendar.cpp:141
Calendar::m_minutes
int m_minutes
Definition: calendar.h:97
Calendar::GetDaylightProportion
double GetDaylightProportion(void)
Definition: calendar.h:73
g_date
class Calendar * g_date
Definition: calendar.cpp:38
aDate
Definition: calendar.h:31
Calendar::Calendar
Calendar(void)
Definition: calendar.cpp:55
Calendar::Date
long Date(void)
Definition: calendar.h:57
Calendar::Reset
void Reset(void)
Definition: calendar.cpp:40
Calendar::m_todayslength
int m_todayslength
Definition: calendar.h:95
Calendar::m_olddays
long m_olddays
Definition: calendar.h:87
Calendar::GetFirstYear
int GetFirstYear(void)
Definition: calendar.h:65
Calendar::m_day_in_month
int m_day_in_month
Definition: calendar.h:90
Calendar::OldDays
long OldDays(void)
Definition: calendar.h:60
Calendar::GetLastYear
int GetLastYear(void)
Definition: calendar.h:66
Calendar::m_daylength
static int m_daylength[]
The length of the day between sun up and sun down im minutes (DK - Jutland)
Definition: calendar.h:102
Calendar::m_month
int m_month
Definition: calendar.h:92
aDate::day
int day
Definition: calendar.h:35
Calendar::m_simulationyear
int m_simulationyear
Definition: calendar.h:94
Calendar::m_lastyear
int m_lastyear
Definition: calendar.h:89
Calendar::DayInYear
int DayInYear(void)
Definition: calendar.h:58
Calendar::TickMinute
bool TickMinute(void)
Definition: calendar.cpp:106
Calendar::TickMinute10
bool TickMinute10(void)
Definition: calendar.cpp:117
Calendar::MarchFirst
bool MarchFirst(void)
Definition: calendar.h:75
Calendar::m_date
long m_date
Definition: calendar.h:86
Calendar::m_janfirst
bool m_janfirst
Definition: calendar.h:99
Calendar::JanFirst
bool JanFirst(void)
Definition: calendar.h:74
Calendar::GlobalDate
long GlobalDate(int a_day, int a_month, int a_year)
Definition: calendar.cpp:61
Calendar::m_year
int m_year
Definition: calendar.h:93
Calendar::GetMinute
int GetMinute(void)
Definition: calendar.h:70