00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_STATS_EPOCH_TRACKER_HH_
00023 # define WIFI_STATS_EPOCH_TRACKER_HH_
00024
00025 # include <vector>
00026 # include <stdexcept>
00027
00028 # include <boost/optional.hpp>
00029
00030 # include <wipal/tool/microseconds.hh>
00031
00032 namespace wpl
00033 {
00034
00035 namespace wifi
00036 {
00037
00038 namespace stats
00039 {
00040
00041 template <class T, unsigned EpochLength>
00042 struct epoch_tracker
00043 {
00044 epoch_tracker();
00045
00046 void restart();
00047 int update(const tool::microseconds& timestamp);
00048 const std::vector<T>& epochs() const;
00049 std::vector<T>& epochs();
00050 const T& current() const;
00051 T& current();
00052
00053 private:
00054 std::vector<T> epochs_;
00055 boost::optional<tool::microseconds> epoch_start_;
00056 unsigned epoch_idx_;
00057 };
00058
00059 struct non_increasing_timestamp: public std::invalid_argument
00060 {
00061 non_increasing_timestamp(const std::string& what);
00062 };
00063
00064 }
00065
00066 }
00067
00068 }
00069
00070 # include "epoch_tracker.hxx"
00071
00072 #endif // ! WIFI_STATS_EPOCH_TRACKER_HH_