RepastHPC  2.3.1
RelogoAgent.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * RelogoAgent.h
36  *
37  * Created on: Aug 5, 2010
38  * Author: nick
39  */
40 
41 #ifndef RELOGOAGENT_H_
42 #define RELOGOAGENT_H_
43 
44 #include "repast_hpc/Point.h"
45 #include "repast_hpc/AgentId.h"
46 
47 namespace repast {
48 namespace relogo {
49 
50 class Observer;
51 class RelogoContinuousSpaceAdder;
52 class WorldCreator;
53 
54 template<typename GPTransformer, typename Adder>
56 
60 class RelogoAgent: public repast::Agent {
61 
62 protected:
63  friend class RelogoContinuousSpaceAdder;
64  friend class WorldCreator;
65 
66  template<typename GPTransformer, typename Adder>
67  friend class RelogoSharedContinuousSpace;
68 
69  Observer* _observer;
70  Point<double> _location;
71  repast::AgentId _id;
72 
73 public:
74 
82  _observer(observer), _location(0, 0), _id(id) {
83  }
84 
85  virtual ~RelogoAgent() {
86  }
87 
93  virtual repast::AgentId& getId() {
94  return _id;
95  }
96 
102  virtual const repast::AgentId& getId() const {
103  return _id;
104  }
105 
112  return _location;
113  }
114 
119  virtual void hatchCopy(){}
120 
126  double xCor() const;
127 
133  double yCor() const;
134 
140  virtual int pxCor() const = 0;
141 
147  virtual int pyCor() const = 0;
148 
154  double distance(RelogoAgent* obj) const;
155 
161  double distancexy(double x, double y) const;
162 
163 };
164 
165 }
166 
167 }
168 
169 #endif /* RELOGOAGENT_H_ */
repast::relogo::RelogoAgent::yCor
double yCor() const
Gets the y coordinate of the agent's location.
Definition: RelogoAgent.cpp:53
repast::relogo::RelogoAgent::distancexy
double distancexy(double x, double y) const
Gets the distance from this RelogoAgent to the specified point.
Definition: RelogoAgent.cpp:61
repast::relogo::RelogoSharedContinuousSpace
Repast SharedContinuousSpace specialized for Relogo.
Definition: RelogoAgent.h:55
repast::relogo::RelogoAgent::distance
double distance(RelogoAgent *obj) const
Gets the distance from this RelogoAgent to the specified agent.
Definition: RelogoAgent.cpp:57
repast::relogo::RelogoAgent
Base agent for Relogo.
Definition: RelogoAgent.h:60
repast::AgentId
Agent identity information.
Definition: AgentId.h:60
repast::relogo::RelogoAgent::getId
virtual repast::AgentId & getId()
Gets the id of this RelogoAgent.
Definition: RelogoAgent.h:93
repast::Agent
Interface for agent classes.
Definition: AgentId.h:206
repast::relogo::RelogoAgent::getId
virtual const repast::AgentId & getId() const
Gets the const id of this RelogoAgent.
Definition: RelogoAgent.h:102
repast::relogo::RelogoContinuousSpaceAdder
An "Adder" for adding RelogoAgents to RelogoSpaces.
Definition: RelogoContinuousSpaceAdder.h:54
repast::relogo::RelogoAgent::pxCor
virtual int pxCor() const =0
Gets the patch x coordinate of the agent's location.
repast::relogo::RelogoAgent::pyCor
virtual int pyCor() const =0
Gets the patch y coordinate of the agent's location.
repast::relogo::WorldCreator
Creates a the relogo world given some parameters.
Definition: WorldCreator.h:65
repast::relogo::RelogoAgent::location
Point< double > location() const
Gets the location of this RelogoAgent.
Definition: RelogoAgent.h:111
repast::relogo::RelogoAgent::RelogoAgent
RelogoAgent(repast::AgentId id, Observer *observer)
Creates a RelogoAgent with the specified id and managed by the specified Observer.
Definition: RelogoAgent.h:81
repast::relogo::RelogoAgent::hatchCopy
virtual void hatchCopy()
If this ReLogo agent is 'hatched', makes an appropriate copy, setting instance variables as appropria...
Definition: RelogoAgent.h:119
repast::relogo::RelogoAgent::xCor
double xCor() const
Gets the x coordinate of the agent's location.
Definition: RelogoAgent.cpp:49
repast::relogo::Observer
Implementation of a logo Observer.
Definition: Observer.h:110
repast::Point< double >