IBR-DTNSuite  0.10
DeliveryPredictabilityMap.h
Go to the documentation of this file.
1 /*
2  * DeliveryPredictabilityMap.h
3  *
4  * Created on: 08.01.2013
5  * Author: morgenro
6  */
7 
8 #ifndef DELIVERYPREDICTABILITYMAP_H_
9 #define DELIVERYPREDICTABILITYMAP_H_
10 
12 #include "routing/NodeHandshake.h"
13 #include <ibrdtn/data/EID.h>
14 #include <ibrcommon/thread/Mutex.h>
15 #include <map>
16 
17 namespace dtn
18 {
19  namespace routing
20  {
28  public:
30 
32  DeliveryPredictabilityMap(const size_t &time_unit, const float &beta, const float &gamma);
34 
35  virtual const dtn::data::Number& getIdentifier() const;
36  virtual dtn::data::Length getLength() const;
37  virtual std::ostream& serialize(std::ostream& stream) const;
38  virtual std::istream& deserialize(std::istream& stream);
39 
41  {
42  public:
44  : ibrcommon::Exception("The requested value is not available.") { };
45 
46  virtual ~ValueNotFoundException() throw () { };
47  };
48 
49  float get(const dtn::data::EID &neighbor) const throw (ValueNotFoundException);
50  void set(const dtn::data::EID &neighbor, float value);
51  void clear();
52 
58  void update(const dtn::data::EID &origin, const DeliveryPredictabilityMap &dpm, const float &p_encounter_first);
59 
64  void age(const float &p_first_threshold);
65 
69  void toString(std::ostream &stream) const;
70 
71  friend std::ostream& operator<<(std::ostream& stream, const DeliveryPredictabilityMap& map);
72 
73  private:
74  typedef std::map<dtn::data::EID, float> predictmap;
75  predictmap _predictmap;
76 
77  float _beta;
78  float _gamma;
79 
80  dtn::data::Timestamp _lastAgingTime;
81  size_t _time_unit;
82 
83  };
84  } /* namespace routing */
85 } /* namespace dtn */
86 #endif /* DELIVERYPREDICTABILITYMAP_H_ */