GlobalCoordinator.cc

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #include "GlobalCoordinator.h"
00025 
00026 Define_Module(GlobalCoordinator);
00027 
00028 void GlobalCoordinator::initialize()
00029 {
00030     PositionSize = 0;
00031     PeerCount = 0;
00032     Position = NULL;
00033     Seed = par("seed");
00034 
00035     WATCH(PositionSize);
00036 }
00037 
00038 void GlobalCoordinator::handleMessage(cMessage* msg)
00039 {
00040     error("this module doesn't handle messages, it runs only in initialize()");
00041 }
00042 
00043 void GlobalCoordinator::increasePositionSize()
00044 {
00045     Enter_Method_Silent();
00046     PositionSize++;
00047     Vector2D *Temp = new Vector2D[PositionSize];
00048     for(int i=0; i<PositionSize-1; i++)
00049         Temp[i] = this->Position[i];
00050 
00051     delete[] this->Position;
00052     this->Position = Temp;
00053 }
00054 
00055 void GlobalCoordinator::increasePeerCount()
00056 {
00057     Enter_Method_Silent();
00058     PeerCount++;
00059 }
00060 
00061 int GlobalCoordinator::getPeerCount()
00062 {
00063     Enter_Method_Silent();
00064     return PeerCount;
00065 }
00066 
00067 Vector2D& GlobalCoordinator::getPosition(int k)
00068 {
00069     Enter_Method_Silent();
00070     if(k >= PositionSize || k < 0) {
00071         throw cRuntimeError("Array out of bounds exception! getPosition(%d)", k);
00072     }
00073     return Position[k];
00074 }
00075 
00076 void GlobalCoordinator::setPosition(int k, const Vector2D& Position)
00077 {
00078     Enter_Method_Silent();
00079     if(k >= PositionSize || k < 0) {
00080         throw cRuntimeError("Array out of bounds exception! setPosition(%d, ...)", k);
00081     }
00082     this->Position[k] = Position;
00083 }
00084 
00085 unsigned int GlobalCoordinator::getSeed()
00086 {
00087     return Seed;
00088 }

Generated on Wed Mar 25 16:32:48 2009 for OverSim by  doxygen 1.5.5