blob: 955f798bee5e11dc62a3e3f381e0f391e2287a15 [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 Afanasyev2b4c9472012-08-09 15:00:38 -070057 Timeout (const NameComponents &key);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070058
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070059 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060 Rx (const NameComponents &key, Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070061
62 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063 Tx (const NameComponents &key, Ptr<Face> face, uint32_t amount);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070064
Alexander Afanasyev0560eec2012-07-16 15:44:31 -070065 // const LoadStatsNode &
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066 // Get (const NameComponents &key) const;
Alexander Afanasyev0845c092012-07-13 17:45:33 -070067 const LoadStatsNode &
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070068 operator [] (const NameComponents &key) const;
Alexander Afanasyev33364b62012-07-26 17:53:56 -070069
70 void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070071 RemoveFace (Ptr<Face> face);
Alexander Afanasyev0845c092012-07-13 17:45:33 -070072
73private:
74 const LoadStatsNode &
75 WalkLeftRightRoot (tree_type *node);
Alexander Afanasyev33364b62012-07-26 17:53:56 -070076
Alexander Afanasyev0845c092012-07-13 17:45:33 -070077
78private:
79 tree_type m_tree;
80
81 friend std::ostream &
82 operator << (std::ostream &os, const StatsTree &tree);
83};
84
85std::ostream &
86operator << (std::ostream &os, const StatsTree &tree);
87
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070088} // namespace ndnSIM
89} // namespace ndn
90} // namespace ns3
Alexander Afanasyev0845c092012-07-13 17:45:33 -070091
92#endif // STATS_TREE_H