31 #ifndef __adevs_cellspace_h_
32 #define __adevs_cellspace_h_
85 CellSpace(
long int width,
long int height = 1,
long int depth = 1);
87 void add(
Cell* model,
long int x,
long int y = 0,
long int z = 0)
89 space[x][y][z] = model;
93 const Cell*
getModel(
long int x,
long int y = 0,
long int z = 0)
const
95 return space[x][y][z];
100 return space[x][y][z];
121 template <
class X,
class T>
129 space =
new Cell***[w];
130 for (
long int x = 0; x < w; x++)
132 space[x] =
new Cell**[h];
133 for (
long int y = 0; y < h; y++)
135 space[x][y] =
new Cell*[h];
136 for (
long int z = 0; z < d; z++)
138 space[x][y][z] = NULL;
145 template <
class X,
class T>
148 for (
long int x = 0; x < w; x++)
150 for (
long int y = 0; y < h; y++)
152 for (
long int z = 0; z < d; z++)
154 if (space[x][y][z] != NULL)
156 delete space[x][y][z];
159 delete [] space[x][y];
167 template <
class X,
class T>
171 for (
long int x = 0; x < w; x++)
173 for (
long int y = 0; y < h; y++)
175 for (
long int z = 0; z < d; z++)
177 if (space[x][y][z] != NULL)
179 c.insert(space[x][y][z]);
187 template <
class X,
class T>
193 if (event.
x >= 0 && event.
x < w &&
194 event.
y >= 0 && event.
y < h &&
195 event.
z >= 0 && event.
z < d)
198 target = space[
event.x][
event.y][
event.z];
long int getWidth() const
Get the width of the CellSpace.
Definition: adevs_cellspace.h:103
long int z
The z coordinate of the event target.
Definition: adevs_cellspace.h:63
void getComponents(Set< Cell * > &c)
Get the model's set of components.
Definition: adevs_cellspace.h:168
Devs< CellEvent< X >, T > Cell
A component model in the CellSpace.
Definition: adevs_cellspace.h:83
Definition: adevs_set.h:42
void add(Cell *model, long int x, long int y=0, long int z=0)
Insert a model at the x,y,z position.
Definition: adevs_cellspace.h:87
long int getHeight() const
Get the height of the CellSpace.
Definition: adevs_cellspace.h:105
long int x
The x coordinate of the event target.
Definition: adevs_cellspace.h:59
const CellEvent & operator=(const CellEvent< X > &src)
Assignment operator.
Definition: adevs_cellspace.h:53
Definition: adevs_models.h:46
void setParent(Network< X, T > *parent)
Definition: adevs_models.h:96
Definition: adevs_cellspace.h:79
void route(const CellEvent< X > &event, Cell *model, Bag< Event< CellEvent< X >, T > > &r)
Route events within the Cellspace.
Definition: adevs_cellspace.h:188
~CellSpace()
Destructor; this destroys the components as well.
Definition: adevs_cellspace.h:146
X value
The event value.
Definition: adevs_cellspace.h:65
Cell * getModel(long int x, long int y=0, long int z=0)
Get a mutable version of the model at x,y,z.
Definition: adevs_cellspace.h:98
CellSpace(long int width, long int height=1, long int depth=1)
Create an Width x Height x Depth CellSpace with NULL entries in the cell locations.
Definition: adevs_cellspace.h:122
Definition: adevs_cellspace.h:44
long int getDepth() const
Get the depth of the CellSpace.
Definition: adevs_cellspace.h:107
long int y
The y coordinate of the event target.
Definition: adevs_cellspace.h:61
CellEvent()
Default constructor. Sets x = y = z = 0.
Definition: adevs_cellspace.h:48
Definition: adevs_models.h:63
const Cell * getModel(long int x, long int y=0, long int z=0) const
Get the model at location x,y,z.
Definition: adevs_cellspace.h:93
Definition: adevs_models.h:142
CellEvent(const CellEvent< X > &src)
Copy constructor.
Definition: adevs_cellspace.h:50
Definition: adevs_bag.h:45