INET Framework for OMNeT++/OMNEST
BasicMobility.h
Go to the documentation of this file.
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 
00032 
00049 class INET_API BasicMobility : public BasicModule
00050 {
00051   public:
00056     enum BorderPolicy {
00057         REFLECT,       
00058         WRAP,          
00059         PLACERANDOMLY, 
00060         RAISEERROR     
00061     };
00062 
00063   protected:
00065     ChannelControl *cc;
00066 
00068     ChannelControl::HostRef myHostRef;
00069 
00071     cModule* hostPtr;
00072 
00074     Coord pos;
00075 
00076   protected:
00078     virtual void handleMessage(cMessage *msg);
00079 
00081     virtual void initialize(int);
00082 
00084     virtual void finish() {}
00085 
00086   protected:
00088     virtual void handleSelfMsg(cMessage *msg) = 0;
00089 
00098     virtual void updatePosition();
00099 
00101     virtual double getPlaygroundSizeX() const  {return cc->getPgs()->x;}
00102 
00104     virtual double getPlaygroundSizeY() const  {return cc->getPgs()->y;}
00105 
00107     virtual Coord getRandomPosition();
00108 
00115     virtual void reflectIfOutside(Coord& targetPos, Coord& step, double& angle);
00116 
00123     virtual void wrapIfOutside(Coord& targetPos);
00124 
00131     virtual void placeRandomlyIfOutside(Coord& targetPos);
00132 
00136     virtual void raiseErrorIfOutside();
00137 
00141     virtual void handleIfOutside(BorderPolicy policy, Coord& targetPos, Coord& step, double& angle);
00142 
00143 };
00144 
00145 #endif
00146