00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_FRAME_STATS_GROWTH_HXX_
00023 # define WIFI_FRAME_STATS_GROWTH_HXX_
00024
00025 # include <wipal/wifi/frame/stats/growth.hh>
00026
00027 namespace wifi
00028 {
00029
00030 namespace frame
00031 {
00032
00033 namespace stats
00034 {
00035
00036 template <class T, unsigned EL>
00037 void
00038 growth<T, EL>::restart()
00039 {
00040 tracker_.restart();
00041 elements_.clear();
00042 current_elements_.clear();
00043 }
00044
00045 template <class T, unsigned EL>
00046 void
00047 growth<T, EL>::update(const tool::microseconds& timestamp)
00048 {
00049 if (tracker_.update(timestamp))
00050 {
00051 epoch_data& d = tracker_.current();
00052
00053 current_elements_.clear();
00054 d.total_count = 0;
00055 d.current_count = 0;
00056 }
00057 }
00058
00059 template <class T, unsigned EL>
00060 void
00061 growth<T, EL>::update(const T& elt)
00062 {
00063 epoch_data& d = tracker_.current();
00064
00065 if (current_elements_.insert(elt).second)
00066 ++d.current_count;
00067
00068 if (elements_.insert(elt).second)
00069 ++d.total_count;
00070 }
00071
00072 template <class T, unsigned EL>
00073 std::ostream&
00074 growth<T, EL>::print(std::ostream& o) const
00075 {
00076 unsigned total = 0;
00077
00078 BOOST_FOREACH(const epoch_data& e, tracker_.epochs())
00079 {
00080 total += e.total_count;
00081 o << '\t' << e.total_count
00082 << '\t' << total
00083 << '\t' << e.current_count << '\n';
00084 }
00085 return o << std::flush;
00086 }
00087
00088 template <class T, unsigned EL>
00089 growth<T, EL>::epoch_data::epoch_data(): total_count (0),
00090 current_count (0)
00091 {
00092 }
00093
00094 }
00095
00096 }
00097
00098 }
00099
00100 #endif // ! WIFI_FRAME_STATS_GROWTH_HXX_