ProxNodeHandle.cc

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2009 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 
00025 #include "ProxNodeHandle.h"
00026 
00027 // This is the usual value for SimTIme::getMaxTime(), may change with a different SimTime scale.
00028 // This value is declared directly a constant, since SimTime::getMaxTime()
00029 // isn't set yet when the program starts.
00030 #define MAXTIME_DBL 9223372036.854775807
00031 
00032 const Prox Prox::PROX_SELF(0, 1);
00033 const Prox Prox::PROX_UNKNOWN(MAXTIME_DBL, 0);
00034 const Prox Prox::PROX_TIMEOUT(MAXTIME_DBL, 1);
00035 //const Prox Prox::PROX_WAITING = {MAXTIME_DBL, 0.6};
00036 
00037 Prox::operator double() { return proximity; };
00038 Prox::operator simtime_t() { return (proximity >= MAXTIME_DBL)
00039                                    ? MAXTIME : proximity; };
00040 
00041 Prox::Prox() {}
00042 Prox::Prox(simtime_t prox) : proximity(SIMTIME_DBL(prox)), accuracy(1) {}
00043 Prox::Prox(simtime_t prox, double acc) : proximity(SIMTIME_DBL(prox)), accuracy(acc) {}
00044 Prox::Prox(double prox, double acc) : proximity(prox), accuracy(acc) {}
00045 
00046 bool Prox::operator==(Prox p) const { return proximity == p.proximity && accuracy == p.accuracy; }
00047 bool Prox::operator!=(Prox p) const { return !(*this == p); }
00048 
00049 ProxNodeHandle::ProxNodeHandle()
00050 {
00051     // TODO Auto-generated constructor stub
00052 
00053 }
00054 
00055 ProxNodeHandle::~ProxNodeHandle()
00056 {
00057     // TODO Auto-generated destructor stub
00058 }
00059 
00060 ProxNodeHandle::ProxNodeHandle(const NodeHandle& nodeHandle)
00061 : NodeHandle(nodeHandle), prox(prox)
00062 {
00063     //...
00064 }
00065 
00066 ProxNodeHandle::ProxNodeHandle(const NodeHandle& nodeHandle, const Prox& prox)
00067 : NodeHandle(nodeHandle), prox(prox)
00068 {
00069     //...
00070 }
00071 
00072 std::ostream& operator<<(std::ostream& os, const Prox& prox)
00073 {
00074     if (prox == Prox::PROX_SELF) os << "[self]";
00075     else if (prox == Prox::PROX_UNKNOWN) os << "[unknown]";
00076     else if (prox == Prox::PROX_TIMEOUT) os << "[timeout]";
00077     else {
00078         os << prox.proximity;
00079         if (prox.accuracy != 1) os << " (a=" << prox.accuracy << ")";
00080     }
00081    return os;
00082 }
00083 

Generated on Tue Sep 8 17:26:54 2009 for OverSim by  doxygen 1.5.8