OverSim
ProxNodeHandle.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2009 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
25 #ifndef PROXNODEHANDLE_H_
26 #define PROXNODEHANDLE_H_
27 
28 #include <cfloat>
29 
30 #include "NodeHandle.h"
31 
32 
33 struct Prox
34 {
35  static const Prox PROX_SELF;
36  static const Prox PROX_UNKNOWN;
37  static const Prox PROX_TIMEOUT;
38  static const Prox PROX_WAITING;
39 
40  double proximity; // [0 - INF)
41  double accuracy; // [0 - 1] 1: exact value, 0: no information available
42 
43  operator double();
44  operator simtime_t();
45 
46  Prox();
47  Prox(simtime_t prox);
48  Prox(simtime_t prox, double acc);
49  Prox(double prox, double acc);
50 
51  bool operator==(Prox p) const;
52  bool operator!=(Prox p) const;
53 
54  friend std::ostream& operator<<(std::ostream& os, const Prox& prox);
55 };
56 
57 struct ProxKey
58 {
59  ProxKey(const Prox& prox, const OverlayKey& key) : prox(prox), key(key) { };
60  Prox prox;
62 };
63 
64 
65 class ProxNodeHandle : public NodeHandle
66 {
67  protected:
69 
70  public:
73  ProxNodeHandle(const NodeHandle& nodeHandle);
74  ProxNodeHandle(const NodeHandle& nodeHandle, const Prox& prox);
75  virtual ~ProxNodeHandle() { };
76 
77  inline void setProx(Prox prox) { this->prox = prox; };
78  inline Prox getProx() const { return prox; };
79 };
80 
82 {
83  protected:
85 
86  public:
89  ProxTransportAddress(const TransportAddress& transportAddress);
90  ProxTransportAddress(const TransportAddress& transportAddress,
91  const Prox& prox);
92  virtual ~ProxTransportAddress() { };
93 
94  inline void setProx(Prox prox) { this->prox = prox; };
95  inline Prox getProx() const { return prox; };
96 };
97 
98 std::ostream& operator<<(std::ostream& os,
99  const ProxTransportAddress& address);
100 
101 #endif /* PROXNODEHANDLE_H_ */