Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

BasicMobility.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        BasicMobility.h
00003  *
00004  * author:      Daniel Willkomm, Andras Varga
00005  *
00006  * copyright:   (C) 2004 Telecommunication Networks Group (TKN) at
00007  *              Technische Universitaet Berlin, Germany.
00008  *
00009  *              (C) 2005 Andras Varga
00010  *
00011  *              This program is free software; you can redistribute it
00012  *              and/or modify it under the terms of the GNU General Public
00013  *              License as published by the Free Software Foundation; either
00014  *              version 2 of the License, or (at your option) any later
00015  *              version.
00016  *              For further information see file COPYING
00017  *              in the top level directory
00018  ***************************************************************************
00019  * part of:     framework implementation developed by tkn
00020  **************************************************************************/
00021 
00022 
00023 #ifndef BASIC_MOBILITY_H
00024 #define BASIC_MOBILITY_H
00025 
00026 #include <omnetpp.h>
00027 
00028 #include "BasicModule.h"
00029 #include "ChannelControl.h"
00030 #include "Coord.h"
00031 #include "HostMove.h"
00032 
00060 class BasicMobility : public BasicModule
00061 {
00062   public:
00069     enum BorderPolicy {
00070         REFLECT,       
00071         WRAP,          
00072         PLACERANDOMLY, 
00073         RAISEERROR     
00074     };
00075 
00081     enum BasicMobilityMsgKinds {
00082         MOVE_HOST = 1050198237,
00083   MOVE_TO_BORDER,
00084   LAST_BASIC
00085     };
00086 
00090     enum BorderHandling {
00091   NOWHERE,   
00092         X_SMALLER, 
00093   X_BIGGER,  
00094   Y_SMALLER, 
00095   Y_BIGGER   
00096     };
00097 
00098   protected:
00100     ChannelControl *cc;
00101 
00103     cModule* hostPtr;
00104     int hostId;
00105     
00107     HostMove move;
00109     int moveCategory;
00110     
00112     double updateInterval;
00113 
00115     cMessage* moveMsg;
00116 
00118     bool coreDebug;
00119 
00120   public:
00121     Module_Class_Members( BasicMobility , BasicModule , 0 );
00122 
00124     void handleMessage(cMessage *msg);
00125 
00127     virtual void initialize(int);
00128 
00130     virtual void finish(){};
00131 
00132   protected:
00134     virtual void handleSelfMsg( cMessage* );
00135     
00137     virtual void handleBorderMsg( cMessage* );
00138     
00148     virtual void makeMove(){
00149   error("BasicMobility does not move the host");
00150     };
00151 
00153     virtual Coord getRandomPosition();
00154 
00156     void updatePosition();
00157 
00159     double playgroundSizeX() const  {return cc->getPgs()->x;}
00160 
00162     double playgroundSizeY() const  {return cc->getPgs()->y;}
00163 
00172 
00174     bool handleIfOutside(BorderPolicy, Coord&, Coord&, Coord&, double&);
00175 
00188     virtual void fixIfHostGetsOutside(){
00189   error("fixIfHostGetsOutside has to be redefined by the user");
00190     };
00191 
00196     BorderHandling checkIfOutside( Coord, Coord& );
00197 
00199     void goToBorder( BorderPolicy, BorderHandling, Coord&, Coord& );
00200 
00205     void reflectIfOutside(BorderHandling, Coord&, Coord&, Coord&, double&);
00206 
00211     void wrapIfOutside(BorderHandling, Coord&, Coord&);
00212 
00217     void placeRandomlyIfOutside( Coord& );
00218 
00221 };
00222 
00223 #endif
00224 

Generated on Fri Jan 12 08:29:32 2007 for Mobility Framework by  doxygen 1.4.4