00001 /* 00002 * Copyright 2007 Baylor University 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef _PROPHET_STATS_H_ 00018 #define _PROPHET_STATS_H_ 00019 00020 #include <map> 00021 #include "Bundle.h" 00022 00023 namespace prophet 00024 { 00025 00030 struct StatsEntry 00031 { 00032 StatsEntry() 00033 : p_max_(0.0), mopr_(0.0), lmopr_(0.0) {} 00034 00035 double p_max_; 00036 double mopr_; 00037 double lmopr_; 00038 }; // StatsEntry 00039 00044 class Stats 00045 { 00046 public: 00050 Stats() 00051 : dropped_(0) {} 00052 00056 ~Stats(); 00057 00062 void update_stats(const Bundle* b, double p); 00063 00068 double get_p_max(const Bundle* b) const; 00069 00075 double get_mopr(const Bundle* b) const; 00076 00082 double get_lmopr(const Bundle* b) const; 00083 00087 void drop_bundle(const Bundle* b); 00088 00093 u_int dropped() const { return dropped_; } 00094 00098 size_t size() const { return pstats_.size(); } 00099 00100 protected: 00101 typedef std::map<u_int32_t,StatsEntry*> pstats; 00102 typedef std::map<u_int32_t,StatsEntry*>::iterator iterator; 00103 typedef std::map<u_int32_t,StatsEntry*>::const_iterator 00104 const_iterator; 00105 00109 StatsEntry* find(const Bundle* b); 00110 00111 u_int dropped_; 00112 mutable pstats pstats_; 00113 }; // Stats 00114 00115 }; // namespace prophet 00116 00117 #endif // _PROPHET_STATS_H_