blob: bcab66d949c68e985f13bbc66fb006134e913f4f [file] [log] [blame]
Alexander Afanasyev0845c092012-07-13 17:45:33 -07001/* -*- 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 STATS_TREE_H
22#define STATS_TREE_H
23
Alexander Afanasyev1a2df6a2012-08-17 13:21:51 -070024#include "../trie/trie.h"
Alexander Afanasyev0845c092012-07-13 17:45:33 -070025#include "load-stats-node.h"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070026#include "ns3/ndn-name-components.h"
Alexander Afanasyev0845c092012-07-13 17:45:33 -070027#include "ns3/ptr.h"
28
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070029namespace ns3 {
30namespace ndn {
31namespace ndnSIM {
Alexander Afanasyev0845c092012-07-13 17:45:33 -070032
33class StatsTree
34{
35public:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070036 typedef trie< NameComponents,
Alexander Afanasyev0845c092012-07-13 17:45:33 -070037 non_pointer_traits< LoadStatsNode >, void* > tree_type;
38
39 StatsTree ();
40
41 void
42 Step ();
43
44 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070045 NewPitEntry (const NameComponents &key);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070046
47 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070048 Incoming (const NameComponents &key, Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070049
50 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070051 Outgoing (const NameComponents &key, Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070052
53 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070054 Satisfy (const NameComponents &key);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070055
56 void
Alexander Afanasyevc7719612012-08-30 17:42:20 -070057 RemoveFromStats (const NameComponents &key);
58
59 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060 Timeout (const NameComponents &key);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070061
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070062 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063 Rx (const NameComponents &key, Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070064
65 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066 Tx (const NameComponents &key, Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070067
Alexander Afanasyev0560eec2012-07-16 15:44:31 -070068 // const LoadStatsNode &
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070069 // Get (const NameComponents &key) const;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070070 const LoadStatsNode &
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070071 operator [] (const NameComponents &key) const;
Alexander Afanasyev33364b62012-07-26 17:53:56 -070072
73 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070074 RemoveFace (Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070075
76private:
77 const LoadStatsNode &
78 WalkLeftRightRoot (tree_type *node);
Alexander Afanasyev33364b62012-07-26 17:53:56 -070079
Alexander Afanasyev0845c092012-07-13 17:45:33 -070080
81private:
82 tree_type m_tree;
83
84 friend std::ostream &
85 operator << (std::ostream &os, const StatsTree &tree);
86};
87
88std::ostream &
89operator << (std::ostream &os, const StatsTree &tree);
90
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070091} // namespace ndnSIM
92} // namespace ndn
93} // namespace ns3
Alexander Afanasyev0845c092012-07-13 17:45:33 -070094
95#endif // STATS_TREE_H