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 #ifndef __COORDBASEDROUTING_H_ 00025 #define __COORDBASEDROUTING_H_ 00026 00027 #include <omnetpp.h> 00028 #include <OverlayKey.h> 00029 #include <TransportAddress.h> 00030 00031 class GlobalNodeList; 00032 00033 00039 class CBRArea 00040 { 00041 public: 00042 CBRArea(uint8_t dim); 00043 ~CBRArea() {}; 00044 00045 std::vector<double> min; 00046 std::vector<double> max; 00047 std::string prefix; 00048 }; 00049 00050 class CoordBasedRouting : public cSimpleModule 00051 { 00052 protected: 00057 virtual void initialize(); 00058 void finish(); 00059 00060 private: 00065 void parseSource(const char* areaCoordinateSource); 00066 00071 std::string getPrefix(const std::vector<double>& coords) const; 00072 00078 bool checkDimensions(uint8_t dims) const; 00079 00080 public: 00087 OverlayKey getNodeId(const std::vector<double>& coords, 00088 uint8_t bpd, uint8_t length) const; 00089 00094 uint8_t getXmlDimensions() const { return xmlDimensions; } 00095 00096 double getEuclidianDistanceByKeyAndCoords(const OverlayKey& destKey, 00097 const std::vector<double>& nodeCoords, 00098 uint8_t bpd) const; 00099 00100 private: 00101 static const std::string NOPREFIX; 00102 00103 const char* areaCoordinateSource; 00104 uint8_t cbrStartAtDigit; 00105 uint8_t cbrStopAtDigit; 00106 uint8_t xmlDimensions; 00107 00108 std::vector<CBRArea*> CBRAreaPool; 00109 GlobalNodeList* globalNodeList; 00110 }; 00111 #endif