IBR-DTN  1.0.0
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  {
27  class DeliveryPredictabilityMap : public NeighborDataSetImpl, public NodeHandshakeItem, public ibrcommon::Mutex {
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 
40  class ValueNotFoundException : public ibrcommon::Exception
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  size_t size() const;
53 
59  void update(const dtn::data::EID &origin, const DeliveryPredictabilityMap &dpm, const float &p_encounter_first);
60 
65  void age(const float &p_first_threshold);
66 
70  void toString(std::ostream &stream) const;
71 
72  friend std::ostream& operator<<(std::ostream& stream, const DeliveryPredictabilityMap& map);
73 
77  void store(std::ostream &output) const;
78 
82  void restore(std::istream &input);
83 
84  private:
85  typedef std::map<dtn::data::EID, float> predictmap;
86  predictmap _predictmap;
87 
88  float _beta;
89  float _gamma;
90 
91  dtn::data::Timestamp _lastAgingTime;
92  size_t _time_unit;
93 
94  };
95  } /* namespace routing */
96 } /* namespace dtn */
97 #endif /* DELIVERYPREDICTABILITYMAP_H_ */
void update(const dtn::data::EID &origin, const DeliveryPredictabilityMap &dpm, const float &p_encounter_first)
friend std::ostream & operator<<(std::ostream &stream, const DeliveryPredictabilityMap &map)
size_t Length
Definition: Number.h:33
void set(const dtn::data::EID &neighbor, float value)
This class keeps track of the predictablities to see a specific EID.
virtual std::ostream & serialize(std::ostream &stream) const
virtual dtn::data::Length getLength() const
virtual const dtn::data::Number & getIdentifier() const
void age(const float &p_first_threshold)
virtual std::istream & deserialize(std::istream &stream)