ALMaSS Partridge ODdox  1.1
The partridge model description following ODdox protocol
Partridge_Base Class Reference

Base class for all partridge classes. More...

#include <Partridge_All.h>

Inheritance diagram for Partridge_Base:
TAnimal TALMaSSObject Partridge_Chick Partridge_Clutch Partridge_Female Partridge_Male Partridge_Chick2

Public Member Functions

Partridge_Object GetObjectType ()
 Supply object type. More...
 
bool GetUncleStatus ()
 Supply uncle status. More...
 
void SetUncleStatus (bool a_Status)
 Set uncle status. More...
 
bool PossibleMate (Partridge_Base *a_partridge)
 Can we mate? More...
 
virtual bool ArePaired ()
 Overridden base function. More...
 
Partridge_CoveyGetCovey (void)
 Supply covey pointer. More...
 
Partridge_State GetState (void)
 Supply state. More...
 
void SetState (Partridge_State a_pars)
 Set state. More...
 
int GetFamily (void)
 Supply family ID. More...
 
int GetAge (void)
 Supply age. More...
 
void SetAge (int a_age)
 Set age. More...
 
long GetID (void)
 Supply ID. More...
 
void SetFamily (unsigned int family)
 Set family ID. More...
 
void SetCovey (Partridge_Covey *a_covey)
 Set covey pointer. More...
 
void MakeCovey ()
 Create our own covey. More...
 
void SwitchCovey (Partridge_Covey *a_covey)
 Swap coveys. More...
 
 Partridge_Base (int a_born_x, int a_born_y, int a_x, int a_y, int a_family_counter, Partridge_Covey *a_covey, Landscape *a_map, Partridge_Population_Manager *a_manager)
 Constructor for Partridge_Base. More...
 
virtual ~Partridge_Base (void)
 Destructor. More...
 
virtual void CopyMyself (int a_Ptype)
 Duplicate this object. More...
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void BeginStep (void)
 BeingStep behaviour - must be implemented in descendent classes. More...
 
virtual void Step (void)
 Step behaviour - must be implemented in descendent classes. More...
 
virtual void EndStep (void)
 EndStep behaviour - must be implemented in descendent classes. More...
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
virtual bool OnFarmEvent (FarmToDo)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Public Attributes

Partridge_Population_Managerm_OurPopulationManager
 Pointer to the population manager. More...
 

Protected Member Functions

virtual bool DailyMortality ()
 Background mortality test. More...
 
virtual void CheckMatePointers ()
 Debug. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Protected Attributes

int m_signal
 Used to pass information to outputs. More...
 
long m_id
 Individual bird ID. More...
 
int m_family_counter
 Family ID. More...
 
int m_age
 Age in days. More...
 
int m_born_x
 x-coord of birth More...
 
int m_born_y
 y-coord of birth More...
 
bool m_UncleStatus
 If has uncle status in the covey. More...
 
Partridge_Object m_object_type
 Type of pob object this is. More...
 
Partridge_Coveym_covey
 Pointer to the covey. More...
 
Partridge_State m_state
 Current behavioural state. More...
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Detailed Description

Base class for all partridge classes.

Definition at line 401 of file Partridge_All.h.

Constructor & Destructor Documentation

◆ Partridge_Base()

Partridge_Base::Partridge_Base ( int  a_born_x,
int  a_born_y,
int  a_x,
int  a_y,
int  a_family_counter,
Partridge_Covey a_covey,
Landscape a_map,
Partridge_Population_Manager a_manager 
)

Constructor for Partridge_Base.

If a_flock is NULL, then assume this is an animal created during population manager initialization and that covey creation/addtion is controlled by the calling method.

Definition at line 156 of file Partridge_All.cpp.

157  : TAnimal( a_x, a_y, a_map )
158  {
159  m_age = 0;
160  m_born_x = a_born_x;
161  m_born_y = a_born_y;
162  m_UncleStatus = false;
163  m_family_counter = a_family_counter;
164  m_id = g_partridge_id++;
165  m_covey = a_covey;
166  // **CJT** NB it is the responsibility of the calling method
167  // to ensure that if a_covey is NULL, then the bird is added later
168  if ( m_covey ) m_covey->AddMember( this );
170  m_OurPopulationManager = a_manager;
171  m_signal = -9999; // used to trap non-set signal output
172 }

References Partridge_Covey::AddMember(), g_partridge_id, m_age, m_born_x, m_born_y, m_covey, m_family_counter, m_id, m_OurPopulationManager, m_signal, m_state, m_UncleStatus, and pars_Initiation.

◆ ~Partridge_Base()

Partridge_Base::~Partridge_Base ( void  )
virtual

Destructor.

The destructor removes an animal from its flock.

Definition at line 192 of file Partridge_All.cpp.

193 {
194  // Line removed because it causes all kinds of concurrency problems
195  // removal from covey must occur when the bird is killed, not later in the day
196  // m_covey->RemoveMember( this );
197 }

Member Function Documentation

◆ ArePaired()

virtual bool Partridge_Base::ArePaired ( )
inlinevirtual

Overridden base function.

Reimplemented in Partridge_Female, and Partridge_Male.

Definition at line 450 of file Partridge_All.h.

450 { return false; }

◆ CheckMatePointers()

virtual void Partridge_Base::CheckMatePointers ( )
inlineprotectedvirtual

Debug.

Reimplemented in Partridge_Female, and Partridge_Male.

Definition at line 426 of file Partridge_All.h.

426 {;}

Referenced by Partridge_Clutch::Step().

◆ CopyMyself()

void Partridge_Base::CopyMyself ( int  a_Ptype)
virtual

Duplicate this object.

A method required only for experimental manipulations - e.g. sudden doubling of population size.

Definition at line 239 of file Partridge_All.cpp.

239  {
240  AdultPartridge_struct * aps;
241  aps = new AdultPartridge_struct;
242  aps->bx = m_born_x;
243  aps->by = m_born_y;
244  aps->x = m_Location_x;
245  aps->y = m_Location_y;
246  aps->L = m_OurLandscape;
247  aps->family_counter = random(1000000);
248  aps->age = m_age;
249  if (a_Ptype==pob_Male) {
250  aps->sex=true;
251  } else {
252  aps->sex=false;
253  }
255  delete aps;
256 }

References AdultPartridge_struct::age, Partridge_struct::bx, Partridge_struct::by, Partridge_Population_Manager::CreateCloneObjects(), Partridge_struct::family_counter, Partridge_struct::L, m_age, m_born_x, m_born_y, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, m_OurPopulationManager, pob_Male, AdultPartridge_struct::sex, Partridge_struct::x, and Partridge_struct::y.

Referenced by Partridge_Population_Manager::Catastrophe(), and Partridge_Population_Manager::MaleImmigration().

◆ DailyMortality()

bool Partridge_Base::DailyMortality ( void  )
protectedvirtual

Background mortality test.

This should not really be used.

Reimplemented in Partridge_Female, Partridge_Male, Partridge_Chick2, Partridge_Chick, and Partridge_Clutch.

Definition at line 228 of file Partridge_All.cpp.

229 {
230  int chance = random( 100000 );
231  if ( chance < cfg_par_base_mortality.value() ) return true;
232  return false;
233 }

References cfg_par_base_mortality, and CfgInt::value().

◆ GetAge()

int Partridge_Base::GetAge ( void  )
inline

Supply age.

Definition at line 472 of file Partridge_All.h.

472  {
473  return m_age;
474  }

References m_age.

Referenced by Partridge_Population_Manager::DoFirst(), and Partridge_Covey::SupplyChickAge().

◆ GetCovey()

Partridge_Covey* Partridge_Base::GetCovey ( void  )
inline

Supply covey pointer.

Definition at line 453 of file Partridge_All.h.

453  {
454  return m_covey;
455  }

References m_covey.

Referenced by Partridge_Population_Manager::DissolveCovey().

◆ GetFamily()

int Partridge_Base::GetFamily ( void  )
inline

◆ GetID()

long Partridge_Base::GetID ( void  )
inline

Supply ID.

Definition at line 482 of file Partridge_All.h.

482  {
483  return m_id;
484  }

References m_id.

Referenced by Partridge_Covey::RemoveMember().

◆ GetObjectType()

Partridge_Object Partridge_Base::GetObjectType ( )
inline

Supply object type.

Definition at line 432 of file Partridge_All.h.

432  {
433  return m_object_type;
434  }

References m_object_type.

Referenced by Partridge_Population_Manager::DissolveCovey(), and Partridge_Communication::PassMessage().

◆ GetState()

Partridge_State Partridge_Base::GetState ( void  )
inline

Supply state.

Definition at line 457 of file Partridge_All.h.

457  {
458  return m_state;
459  }

References m_state.

◆ GetUncleStatus()

bool Partridge_Base::GetUncleStatus ( )
inline

Supply uncle status.

Definition at line 437 of file Partridge_All.h.

437  {
438  return m_UncleStatus;
439  }

References m_UncleStatus.

Referenced by Partridge_Population_Manager::DissolveCovey().

◆ MakeCovey()

void Partridge_Base::MakeCovey ( void  )

Create our own covey.

Only called when a bird must make a new covey the bird will be the first member and the only one on calling. NB all housekeeping in the population manager is handled by the Covey constructor. The caller is responsible for removing the bird from the present covey before this call is made (or immediately after).

Definition at line 206 of file Partridge_All.cpp.

References m_covey, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, and m_OurPopulationManager.

Referenced by Partridge_Population_Manager::DissolveCovey(), and Partridge_Male::MFindingMate().

◆ PossibleMate()

bool Partridge_Base::PossibleMate ( Partridge_Base a_partridge)

Can we mate?

Checks whether the supplied bird is a potential mate, or is too closely related.

Definition at line 179 of file Partridge_All.cpp.

180 {
181  if ( ( a_partridge->GetFamily() < m_family_counter - 1 || a_partridge->GetFamily() > m_family_counter + 1 )
182  // Possible age check?
183  )
184  {
185  return true;
186  }
187  return false;
188 }

References GetFamily(), and m_family_counter.

◆ SetAge()

void Partridge_Base::SetAge ( int  a_age)
inline

Set age.

Definition at line 477 of file Partridge_All.h.

477  {
478  m_age = a_age;
479  }

References m_age.

Referenced by Partridge_Population_Manager::CreateCloneObjects().

◆ SetCovey()

void Partridge_Base::SetCovey ( Partridge_Covey a_covey)
inline

Set covey pointer.

Definition at line 492 of file Partridge_All.h.

492  {
493  m_covey = a_covey;
494  }

References m_covey.

Referenced by Partridge_Population_Manager::CreateCloneObjects(), Partridge_Population_Manager::CreateInitialObjects(), and Partridge_Covey::ManagerCheckMerge().

◆ SetFamily()

void Partridge_Base::SetFamily ( unsigned int  family)
inline

Set family ID.

Definition at line 487 of file Partridge_All.h.

487  {
488  m_family_counter = family;
489  }

References m_family_counter.

Referenced by Partridge_Male::OnMating().

◆ SetState()

void Partridge_Base::SetState ( Partridge_State  a_pars)
inline

Set state.

Definition at line 462 of file Partridge_All.h.

462  {
463  m_state = a_pars;
464  }

References m_state.

Referenced by Partridge_Population_Manager::Catastrophe(), and Partridge_Covey::SetUncle().

◆ SetUncleStatus()

void Partridge_Base::SetUncleStatus ( bool  a_Status)
inline

◆ SwitchCovey()

void Partridge_Base::SwitchCovey ( Partridge_Covey a_covey)

Swap coveys.

Moves the bird from its cuurent covey to the one supplied.

Definition at line 216 of file Partridge_All.cpp.

217 {
218  m_covey->RemoveMember( this );
219  m_covey = a_covey;
220  m_covey->AddMember( this );
221 }

References Partridge_Covey::AddMember(), m_covey, and Partridge_Covey::RemoveMember().

Referenced by Partridge_Female::OnMating().

Member Data Documentation

◆ m_age

◆ m_born_x

int Partridge_Base::m_born_x
protected

x-coord of birth

Definition at line 412 of file Partridge_All.h.

Referenced by Partridge_Chick2::ChMaturing(), CopyMyself(), and Partridge_Base().

◆ m_born_y

int Partridge_Base::m_born_y
protected

y-coord of birth

Definition at line 414 of file Partridge_All.h.

Referenced by Partridge_Chick2::ChMaturing(), CopyMyself(), and Partridge_Base().

◆ m_covey

◆ m_family_counter

◆ m_id

long Partridge_Base::m_id
protected

Individual bird ID.

Definition at line 406 of file Partridge_All.h.

Referenced by GetID(), and Partridge_Base().

◆ m_object_type

◆ m_OurPopulationManager

◆ m_signal

int Partridge_Base::m_signal
protected

◆ m_state

◆ m_UncleStatus

bool Partridge_Base::m_UncleStatus
protected

If has uncle status in the covey.

Definition at line 416 of file Partridge_All.h.

Referenced by GetUncleStatus(), Partridge_Male::MFindingMate(), Partridge_Female::OnWaitForMale(), Partridge_Base(), and SetUncleStatus().


The documentation for this class was generated from the following files:
Partridge_Base::m_object_type
Partridge_Object m_object_type
Type of pob object this is.
Definition: Partridge_All.h:418
Partridge_Covey::RemoveMember
int RemoveMember(Partridge_Base *a_former_member)
Remove a member from the covey.
Definition: Partridge_Covey.cpp:1664
Partridge_Base::m_family_counter
int m_family_counter
Family ID.
Definition: Partridge_All.h:408
Partridge_struct::family_counter
int family_counter
Definition: Partridge_All.h:350
Partridge_Base::m_state
Partridge_State m_state
Current behavioural state.
Definition: Partridge_All.h:422
Partridge_struct::L
Landscape * L
Definition: Partridge_All.h:348
TAnimal::m_OurLandscape
Landscape * m_OurLandscape
Definition: populationmanager.h:229
Partridge_struct::x
int x
Definition: Partridge_All.h:344
Partridge_Base::m_id
long m_id
Individual bird ID.
Definition: Partridge_All.h:406
TAnimal::TAnimal
TAnimal(int x, int y, Landscape *L)
Definition: PopulationManager.cpp:1367
TAnimal::m_Location_y
int m_Location_y
Definition: populationmanager.h:228
cfg_par_base_mortality
static CfgInt cfg_par_base_mortality("PAR_BASE_MORTALITY", CFG_CUSTOM, 0)
Unused.
AdultPartridge_struct::age
int age
Definition: Partridge_All.h:389
Partridge_Base::m_UncleStatus
bool m_UncleStatus
If has uncle status in the covey.
Definition: Partridge_All.h:416
Partridge_Base::m_born_x
int m_born_x
x-coord of birth
Definition: Partridge_All.h:412
Partridge_Covey
The collective for a family of partridges
Definition: Partridge_Covey.h:90
Partridge_Base::m_signal
int m_signal
Used to pass information to outputs.
Definition: Partridge_All.h:404
Partridge_struct::y
int y
Definition: Partridge_All.h:345
AdultPartridge_struct::sex
bool sex
Definition: Partridge_All.h:388
AdultPartridge_struct
Struct to pass adult partridge information.
Definition: Partridge_All.h:386
Partridge_Base::m_age
int m_age
Age in days.
Definition: Partridge_All.h:410
Partridge_Base::GetFamily
int GetFamily(void)
Supply family ID.
Definition: Partridge_All.h:467
Partridge_Base::m_OurPopulationManager
Partridge_Population_Manager * m_OurPopulationManager
Pointer to the population manager.
Definition: Partridge_All.h:430
pars_Initiation
Definition: Partridge_All.h:267
Partridge_struct::by
int by
Definition: Partridge_All.h:347
Partridge_Base::m_born_y
int m_born_y
y-coord of birth
Definition: Partridge_All.h:414
Partridge_struct::bx
int bx
Definition: Partridge_All.h:346
g_partridge_id
static long g_partridge_id
Definition: Partridge_All.cpp:151
Partridge_Population_Manager::CreateCloneObjects
void CreateCloneObjects(int ob_type, AdultPartridge_struct *as)
Definition: Partridge_Population_Manager.cpp:535
Partridge_Covey::AddMember
void AddMember(Partridge_Base *a_new_member)
Definition: Partridge_Covey.cpp:1644
CfgInt::value
int value(void)
Definition: configurator.h:98
Partridge_Base::m_covey
Partridge_Covey * m_covey
Pointer to the covey.
Definition: Partridge_All.h:420
pob_Male
Definition: Partridge_All.h:297
TAnimal::m_Location_x
int m_Location_x
Definition: populationmanager.h:225