RepastHPC  2.3.1
WorldDefinition.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  * WorldDefinition.h
36  *
37  * Created on: Aug 5, 2010
38  * Author: nick
39  */
40 
41 #ifndef WORLDDEFINITION_H_
42 #define WORLDDEFINITION_H_
43 
44 #include <vector>
45 #include "RelogoAgent.h"
46 #include "RelogoLink.h"
47 
48 #include "repast_hpc/SharedNetwork.h"
49 
50 namespace repast {
51 
52 namespace relogo {
53 
54 
55 class RelogoGridAdder;
56 class RelogoSpaceAdder;
57 
62 
63 private:
64 
65  GridDimensions _dims;
66  bool _wrapped;
67  int _buffer;
68  std::vector<Projection<RelogoAgent>*> networks;
69 
70 
71 public:
72 
76  typedef std::vector<Projection<RelogoAgent>*>::const_iterator proj_iter;
77 
90  WorldDefinition(int minX, int minY, int maxX, int maxY, bool wrapped, int buffer);
91  virtual ~WorldDefinition();
92 
101  void defineNetwork(std::string name, bool directed, RelogoLinkContentManager* rlcm);
102 
111  void defineNetwork(bool directed, RelogoLinkContentManager* rlcm);
112 
119  return networks.begin();
120  }
121 
128  return networks.end();
129  }
130 
136  int minX() const {
137  return _dims.origin(0);
138  }
139 
145  int minY() const {
146  return _dims.origin(1);
147  }
148 
154  int maxX() const {
155  return _dims.origin(0) + _dims.extents(0) - 1;
156  }
157 
163  int maxY() const {
164  return _dims.origin(1) + _dims.extents(1) - 1;
165  }
166 
172  const GridDimensions dimensions() const {
173  return _dims;
174  }
175 
176 
182  bool isWrapped() const {
183  return _wrapped;
184  }
185 
191  int buffer() const {
192  return _buffer;
193  }
194 
195 
196 };
197 
198 
199 }
200 
201 }
202 
203 #endif /* WORLDDEFINITION_H_ */
repast::GridDimensions::extents
const Point< double > & extents() const
Gets the extents along each dimension.
Definition: GridDimensions.h:90
repast::relogo::WorldDefinition::buffer
int buffer() const
Gets the size of the grid / space buffer.
Definition: WorldDefinition.h:191
repast::relogo::WorldDefinition::isWrapped
bool isWrapped() const
Gets whether or not the world wraps.
Definition: WorldDefinition.h:182
repast::relogo::WorldDefinition::defineNetwork
void defineNetwork(std::string name, bool directed, RelogoLinkContentManager *rlcm)
Defines a network with the specified name and whether or not the network is directed.
Definition: WorldDefinition.cpp:61
repast::relogo::WorldDefinition::maxX
int maxX() const
Gets the maximum x coordinate of the world.
Definition: WorldDefinition.h:154
repast::relogo::WorldDefinition::dimensions
const GridDimensions dimensions() const
Gets the dimensions of the world expressed as a GridDimensions.
Definition: WorldDefinition.h:172
repast::GridDimensions::origin
const Point< double > & origin() const
Gets the origin.
Definition: GridDimensions.h:83
repast::relogo::WorldDefinition::networks_end
proj_iter networks_end() const
Gets the end of an iterator over the network Projections defined in this WorldDefinition.
Definition: WorldDefinition.h:127
repast::relogo::WorldDefinition::networks_begin
proj_iter networks_begin() const
Gets the start of an iterator over the network Projections defined in this WorldDefinition.
Definition: WorldDefinition.h:118
repast::GridDimensions
Basic structure for specifying grid dimenions.
Definition: GridDimensions.h:58
repast::relogo::WorldDefinition::maxY
int maxY() const
Gets the maximum y coordinate of the world.
Definition: WorldDefinition.h:163
repast::relogo::WorldDefinition::WorldDefinition
WorldDefinition(int minX, int minY, int maxX, int maxY, bool wrapped, int buffer)
Creates a world definition with the specified parameters.
Definition: WorldDefinition.cpp:53
repast::relogo::WorldDefinition::minX
int minX() const
Gets the minimum x coordinate of the world.
Definition: WorldDefinition.h:136
repast::relogo::WorldDefinition
Defines a Relogo world.
Definition: WorldDefinition.h:61
repast::relogo::WorldDefinition::proj_iter
std::vector< Projection< RelogoAgent > * >::const_iterator proj_iter
An iterator over pointers to Projection<RelogoAgent>.
Definition: WorldDefinition.h:76
repast::relogo::WorldDefinition::minY
int minY() const
Gets the minimum y coordinate of the world.
Definition: WorldDefinition.h:145