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-with-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_WITH_INDEX_H_
22
#define PAYLOAD_WITH_INDEX_H_
23
24
namespace
ns3 {
25
namespace
ndn {
26
namespace
ndnSIM {
27
28
template
<
typename
PayloadTraits,
29
typename
IndexTraits>
30
class
payload_with_index
31
{
32
public
:
33
typedef
PayloadTraits::pointer_type iterator;
34
35
typedef
typename
IndexTraits::template index<
36
PayloadTraits,
37
typename
IndexTraits::template container_hook<parent_trie>::type >::type index_container;
38
39
inline
40
payload_with_index
()
41
: index_ (*
this
)
42
{
43
}
44
45
inline
std::pair< iterator, bool >
46
insert (
typename
iterator payload)
47
{
48
bool
ok = policy_.insert (s_iterator_to (item.first));
49
if
(!ok)
50
{
51
item.first->erase ();
// cannot insert
52
return
std::make_pair (end (),
false
);
53
}
54
55
return
item;
56
}
57
58
// inline void
59
// erase (const FullKey &key)
60
// {
61
// iterator foundItem, lastItem;
62
// bool reachLast;
63
// boost::tie (foundItem, reachLast, lastItem) = trie_.find (key);
64
65
// if (!reachLast || lastItem->payload () == PayloadTraits::empty_payload)
66
// return; // nothing to invalidate
67
68
// erase (lastItem);
69
// }
70
71
// inline void
72
// erase (iterator node)
73
// {
74
// if (node == end ()) return;
75
76
// policy_.erase (s_iterator_to (node));
77
// node->erase (); // will do cleanup here
78
// }
79
80
// inline void
81
// clear ()
82
// {
83
// policy_.clear ();
84
// trie_.clear ();
85
// }
86
87
// template<typename Modifier>
88
// bool
89
// modify (iterator position, Modifier mod)
90
// {
91
// if (position == end ()) return false;
92
// if (position->payload () == PayloadTraits::empty_payload) return false;
93
94
// mod (*position->payload ());
95
// policy_.update (position);
96
// return true;
97
// }
98
99
private
:
100
mutable
index_container policy_;
101
};
102
103
}
// ndnSIM
104
}
// ndn
105
}
// ns3
106
107
#endif // PAYLOAD_WITH_POLICY_H_
ns3::ndn::ndnSIM::payload_with_index
Definition:
payload-with-policy.h:30
ndnSIM
utils
trie
payload-with-policy.h
Generated on Mon Jan 19 2015 11:27:04 for ndnSIM by
1.8.7