ALMaSS Hare ODDox  1.1
The hare model description following ODdox protocol
OFirstYearDanger.cpp
Go to the documentation of this file.
1 //
2 // OFirstYearDanger.cpp
3 //
4 /*
5 *******************************************************************************************************
6 Copyright (c) 2011, Christopher John Topping, University of Aarhus
7 All rights reserved.
8 
9 Redistribution and use in source and binary forms, with or without modification, are permitted provided
10 that the following conditions are met:
11 
12 Redistributions of source code must retain the above copyright notice, this list of conditions and the
13 following disclaimer.
14 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
15 the following disclaimer in the documentation and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
20 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
22 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 ********************************************************************************************************
26 */
27 
28 #include "../../Landscape/ls.h"
29 #include "../../Landscape/cropprogs/OFirstYearDanger.h"
30 
31 
32 bool OFirstYearDanger::Do( Farm *a_farm, LE *a_field, FarmEvent *a_ev )
33 {
34  m_farm = a_farm;
35  m_field = a_field;
36  m_ev = a_ev;
37 
38  bool done = false;
39 
40  switch ( m_ev->m_todo )
41  {
42  case ofyd_start:
43  {
44  // ***CJT*** Adjust ending date for this dummy management
45  // plan as needed. FN.
46  int d1 = g_date->OldDays() + g_date->DayInYear( 1,8 );
47  SimpleEvent( d1, ofyd_end, false );
48  }
49  break;
50 
51  case ofyd_end:
52  done = true;
53  break;
54 
55  default:
56  g_msg->Warn( WARN_BUG, "OFirstYearDanger::Do(): "
57  "Unknown event type! ", "" );
58  exit( 1 );
59  }
60 
61  return done;
62 }
63 
64 
65 
FarmEvent
A struct to hold the information required to trigger a farm event.
Definition: farm.h:463
Crop::SimpleEvent
void SimpleEvent(long a_date, int a_todo, bool a_lock)
Adds an event to this crop management.
Definition: farm.cpp:307
ofyd_end
Definition: OFirstYearDanger.h:35
ofyd_start
Definition: OFirstYearDanger.h:34
Crop::m_farm
Farm * m_farm
Definition: farm.h:537
Crop::m_field
LE * m_field
Definition: farm.h:538
FarmEvent::m_todo
int m_todo
Definition: farm.h:469
OFirstYearDanger::Do
bool Do(Farm *a_farm, LE *a_field, FarmEvent *a_ev)
Definition: OFirstYearDanger.cpp:32
Farm
The base class for all farm types.
Definition: farm.h:767
Crop::m_ev
FarmEvent * m_ev
Definition: farm.h:539