NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
payload-policy.h
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 PAYLOAD_POLICY_H_
22
#define PAYLOAD_POLICY_H_
23
24
#include <boost/intrusive/options.hpp>
25
#include <boost/intrusive/list.hpp>
26
27
namespace
ns3 {
28
namespace
ndn {
29
namespace
ndnSIM {
30
34
template
<
class
Member>
35
struct
payload_policy_traits
36
{
37
struct
policy_hook_type
:
public
boost::intrusive::set_member_hook<> {};
38
39
template
<
class
Container>
40
struct
container_hook
41
{
42
typedef
boost::intrusive::member_hook< Container,
43
policy_hook_type
,
44
&Container::policy_hook_ > type;
45
};
46
47
template
<
class
Base,
48
class
Container,
49
class
Hook>
50
struct
policy
51
{
52
typedef
typename
boost::intrusive::list< Container, Hook > policy_container;
53
54
// could be just typedef
55
class
type
:
public
policy_container
56
{
57
public
:
58
typedef
Container parent_trie;
59
60
type
(Base &base)
61
: base_ (base)
62
, max_size_ (100)
63
{
64
}
65
66
inline
void
67
update (
typename
parent_trie::iterator item)
68
{
69
// do relocation
70
policy_container::splice (policy_container::end (),
71
*
this
,
72
policy_container::s_iterator_to (*item));
73
}
74
75
inline
bool
76
insert (
typename
parent_trie::iterator item)
77
{
78
if
(policy_container::size () >= max_size_)
79
{
80
base_.erase (&(*policy_container::begin ()));
81
}
82
83
policy_container::push_back (*item);
84
return
true
;
85
}
86
87
inline
void
88
lookup (
typename
parent_trie::iterator item)
89
{
90
// do relocation
91
policy_container::splice (policy_container::end (),
92
*
this
,
93
policy_container::s_iterator_to (*item));
94
}
95
96
inline
void
97
erase (
typename
parent_trie::iterator item)
98
{
99
policy_container::erase (policy_container::s_iterator_to (*item));
100
}
101
102
inline
void
103
clear ()
104
{
105
policy_container::clear ();
106
}
107
108
inline
void
109
set_max_size (
size_t
max_size)
110
{
111
max_size_ = max_size;
112
}
113
114
inline
size_t
115
get_max_size ()
const
116
{
117
return
max_size_;
118
}
119
120
private
:
121
type
() : base_(*((Base*)0)) { };
122
123
private
:
124
Base &base_;
125
size_t
max_size_;
126
};
127
};
128
};
129
130
}
// ndnSIM
131
}
// ndn
132
}
// ns3
133
134
#endif // PAYLOAD_POLICY_H
ns3::ndn::ndnSIM::payload_policy_traits::policy::type
Definition:
payload-policy.h:55
ns3::ndn::ndnSIM::payload_policy_traits::policy
Definition:
payload-policy.h:50
ns3::ndn::ndnSIM::payload_policy_traits
Traits for policy that keeps items in a sorted order using payload member.
Definition:
payload-policy.h:35
ns3::ndn::ndnSIM::payload_policy_traits::container_hook
Definition:
payload-policy.h:40
ns3::ndn::ndnSIM::payload_policy_traits::policy_hook_type
Definition:
payload-policy.h:37
ndnSIM
utils
trie
payload-policy.h
Generated on Mon Jan 19 2015 11:27:04 for ndnSIM by
1.8.7