Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef LOAD_STATS_NODE_H |
| 22 | #define LOAD_STATS_NODE_H |
| 23 | |
| 24 | #include "load-stats-face.h" |
| 25 | #include <map> |
| 26 | #include "ns3/ptr.h" |
| 27 | |
| 28 | namespace ns3 |
| 29 | { |
| 30 | class CcnxFace; |
| 31 | } |
| 32 | |
| 33 | namespace ndnSIM |
| 34 | { |
| 35 | |
| 36 | // this thing is actually put into a tree node, associated with each "name entry" |
| 37 | |
| 38 | class LoadStatsNode |
| 39 | { |
| 40 | public: |
| 41 | typedef std::map< ns3::Ptr<ns3::CcnxFace>, LoadStatsFace > stats_container; |
| 42 | |
| 43 | LoadStatsNode () {} |
| 44 | LoadStatsNode (const LoadStatsNode &) {} |
| 45 | |
| 46 | void |
| 47 | Step (); |
| 48 | |
| 49 | /** |
| 50 | * Increment face-independent counter |
| 51 | */ |
| 52 | void |
| 53 | NewPitEntry (); |
| 54 | |
| 55 | /** |
| 56 | * Increment counter to incoming list |
| 57 | */ |
| 58 | void |
| 59 | AddIncoming (ns3::Ptr<ns3::CcnxFace> face); |
| 60 | |
| 61 | /** |
| 62 | * Increment counter to outgoing list |
| 63 | */ |
| 64 | void |
| 65 | AddOutgoing (ns3::Ptr<ns3::CcnxFace> face); |
| 66 | |
| 67 | /** |
| 68 | * Increment counter to both incoming and outgoing lists, for all faces |
| 69 | */ |
| 70 | void |
| 71 | Satisfy (); |
| 72 | |
| 73 | /** |
| 74 | * Increment counter to both incoming and outgoing lists, for all faces |
| 75 | */ |
| 76 | void |
| 77 | Timeout (); |
| 78 | |
| 79 | LoadStatsNode & |
| 80 | operator += (const LoadStatsNode &stats); |
| 81 | |
| 82 | inline const stats_container & |
| 83 | incoming () const; |
| 84 | |
| 85 | inline const stats_container & |
| 86 | outgoing () const; |
| 87 | |
| 88 | inline const LoadStatsFace & |
| 89 | pit () const; |
| 90 | |
| 91 | bool |
Alexander Afanasyev | 0560eec | 2012-07-16 15:44:31 -0700 | [diff] [blame] | 92 | IsZero () const; |
| 93 | |
| 94 | bool |
| 95 | operator == (const LoadStatsNode &other) const; |
| 96 | |
Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 97 | bool |
| 98 | operator != (const LoadStatsNode &other) const |
| 99 | { |
Alexander Afanasyev | 0560eec | 2012-07-16 15:44:31 -0700 | [diff] [blame] | 100 | return !(*this == other); |
Alexander Afanasyev | 0845c09 | 2012-07-13 17:45:33 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | LoadStatsNode & |
| 104 | operator = (const LoadStatsNode &other) |
| 105 | { |
| 106 | // don't do any copying at all |
| 107 | return *this; |
| 108 | } |
| 109 | |
| 110 | private: |
| 111 | LoadStatsFace m_pit; |
| 112 | stats_container m_incoming; |
| 113 | stats_container m_outgoing; |
| 114 | |
| 115 | friend std::ostream& |
| 116 | operator << (std::ostream &os, const LoadStatsNode &node); |
| 117 | }; |
| 118 | |
| 119 | inline const LoadStatsNode::stats_container & |
| 120 | LoadStatsNode::incoming () const |
| 121 | { |
| 122 | return m_incoming; |
| 123 | } |
| 124 | |
| 125 | inline const LoadStatsNode::stats_container & |
| 126 | LoadStatsNode::outgoing () const |
| 127 | { |
| 128 | return m_outgoing; |
| 129 | } |
| 130 | |
| 131 | inline const LoadStatsFace & |
| 132 | LoadStatsNode::pit () const |
| 133 | { |
| 134 | return m_pit; |
| 135 | } |
| 136 | |
| 137 | std::ostream& |
| 138 | operator << (std::ostream &os, const LoadStatsNode &node); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | #endif |