OverSim
GlobalCoordinator.cc
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #include "GlobalCoordinator.h"
25 
27 
29 {
30  PositionSize = 0;
31  PeerCount = 0;
32  Position = NULL;
33  Seed = par("seed");
34 
35  WATCH(PositionSize);
36 }
37 
39 {
40  delete[] this->Position;
41 }
42 
44 {
45  error("this module doesn't handle messages, it runs only in initialize()");
46 }
47 
49 {
50  Enter_Method_Silent();
51  PositionSize++;
52  Vector2D *Temp = new Vector2D[PositionSize];
53  for(int i=0; i<PositionSize-1; i++)
54  Temp[i] = this->Position[i];
55 
56  delete[] this->Position;
57  this->Position = Temp;
58 }
59 
61 {
62  Enter_Method_Silent();
63  PeerCount++;
64 }
65 
67 {
68  Enter_Method_Silent();
69  return PeerCount;
70 }
71 
73 {
74  Enter_Method_Silent();
75  if(k >= PositionSize || k < 0) {
76  throw cRuntimeError("Array out of bounds exception! getPosition(%d)", k);
77  }
78  return Position[k];
79 }
80 
81 void GlobalCoordinator::setPosition(int k, const Vector2D& Position)
82 {
83  Enter_Method_Silent();
84  if(k >= PositionSize || k < 0) {
85  throw cRuntimeError("Array out of bounds exception! setPosition(%d, ...)", k);
86  }
87  this->Position[k] = Position;
88 }
89 
91 {
92  return Seed;
93 }