NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
tags.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
tags.hpp
"
23
#include "../encoding/nfd-constants.hpp"
24
25
namespace
ndn
{
26
namespace
lp
{
27
28
#ifdef NDN_LP_KEEP_LOCAL_CONTROL_HEADER
29
30
using
ndn::nfd::INVALID_FACE_ID
;
31
32
LocalControlHeaderFacade::LocalControlHeaderFacade(TagHost& pkt)
33
: m_pkt(pkt)
34
{
35
}
36
37
bool
38
LocalControlHeaderFacade::hasIncomingFaceId
()
const
39
{
40
return
m_pkt.
getTag
<
IncomingFaceIdTag
>() !=
nullptr
;
41
}
42
43
uint64_t
44
LocalControlHeaderFacade::getIncomingFaceId
()
const
45
{
46
shared_ptr<IncomingFaceIdTag> tag = m_pkt.
getTag
<
IncomingFaceIdTag
>();
47
if
(tag ==
nullptr
) {
48
return
INVALID_FACE_ID
;
49
}
50
return
*tag;
51
}
52
53
void
54
LocalControlHeaderFacade::setIncomingFaceId
(uint64_t incomingFaceId)
55
{
56
if
(incomingFaceId ==
INVALID_FACE_ID
) {
57
m_pkt.
removeTag
<
IncomingFaceIdTag
>();
58
return
;
59
}
60
61
auto
tag = make_shared<IncomingFaceIdTag>(incomingFaceId);
62
m_pkt.
setTag
(tag);
63
}
64
65
bool
66
LocalControlHeaderFacade::hasNextHopFaceId
()
const
67
{
68
return
m_pkt.
getTag
<
NextHopFaceIdTag
>() !=
nullptr
;
69
}
70
71
uint64_t
72
LocalControlHeaderFacade::getNextHopFaceId
()
const
73
{
74
shared_ptr<NextHopFaceIdTag> tag = m_pkt.
getTag
<
NextHopFaceIdTag
>();
75
if
(tag ==
nullptr
) {
76
return
INVALID_FACE_ID
;
77
}
78
return
*tag;
79
}
80
81
void
82
LocalControlHeaderFacade::setNextHopFaceId
(uint64_t nextHopFaceId)
83
{
84
if
(nextHopFaceId ==
INVALID_FACE_ID
) {
85
m_pkt.
removeTag
<
NextHopFaceIdTag
>();
86
return
;
87
}
88
89
auto
tag = make_shared<NextHopFaceIdTag>(nextHopFaceId);
90
m_pkt.
setTag
(tag);
91
}
92
93
bool
94
LocalControlHeaderFacade::hasCachingPolicy
()
const
95
{
96
return
m_pkt.
getTag
<
CachePolicyTag
>() !=
nullptr
;
97
}
98
99
LocalControlHeaderFacade::CachingPolicy
100
LocalControlHeaderFacade::getCachingPolicy
()
const
101
{
102
shared_ptr<CachePolicyTag> tag = m_pkt.
getTag
<
CachePolicyTag
>();
103
if
(tag ==
nullptr
) {
104
return
INVALID_POLICY
;
105
}
106
switch
(tag->get().getPolicy()) {
107
case
CachePolicyType::NO_CACHE
:
108
return
NO_CACHE
;
109
default
:
110
return
INVALID_POLICY
;
111
}
112
}
113
114
void
115
LocalControlHeaderFacade::setCachingPolicy
(
CachingPolicy
cachingPolicy)
116
{
117
switch
(cachingPolicy) {
118
case
NO_CACHE
: {
119
m_pkt.
setTag
(make_shared<CachePolicyTag>(
CachePolicy
().setPolicy(
CachePolicyType::NO_CACHE
)));
120
break
;
121
}
122
default
:
123
m_pkt.
removeTag
<
CachePolicyTag
>();
124
break
;
125
}
126
}
127
128
#endif // NDN_LP_KEEP_LOCAL_CONTROL_HEADER
129
130
}
// namespace lp
131
}
// namespace ndn
ndn::TagHost::setTag
void setTag(shared_ptr< T > tag) const
set a tag item
Definition:
tag-host.hpp:80
ndn::lp::CachePolicyType::NO_CACHE
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::TagHost::getTag
shared_ptr< T > getTag() const
get a tag item
Definition:
tag-host.hpp:67
ndn::TagHost::removeTag
void removeTag() const
remove tag item
Definition:
tag-host.hpp:94
ndn::lp::LocalControlHeaderFacade::NO_CACHE
Definition:
tags.hpp:94
ndn::lp::LocalControlHeaderFacade::hasNextHopFaceId
bool hasNextHopFaceId() const
Definition:
tags.cpp:66
ndn::lp::LocalControlHeaderFacade::hasIncomingFaceId
bool hasIncomingFaceId() const
Definition:
tags.cpp:38
ndn::lp::LocalControlHeaderFacade::getIncomingFaceId
uint64_t getIncomingFaceId() const
Definition:
tags.cpp:44
ndn::lp::tlv::CachePolicy
Definition:
tlv.hpp:41
ndn::lp::LocalControlHeaderFacade::setCachingPolicy
void setCachingPolicy(CachingPolicy cachingPolicy)
Definition:
tags.cpp:115
ndn::SimpleTag
provides a tag type for simple types
Definition:
tag.hpp:58
tags.hpp
ndn::lp::LocalControlHeaderFacade::getNextHopFaceId
uint64_t getNextHopFaceId() const
Definition:
tags.cpp:72
ndn::lp::LocalControlHeaderFacade::CachingPolicy
CachingPolicy
Definition:
tags.hpp:92
ndn::lp::LocalControlHeaderFacade::getCachingPolicy
CachingPolicy getCachingPolicy() const
Definition:
tags.cpp:100
ndn::lp::LocalControlHeaderFacade::setIncomingFaceId
void setIncomingFaceId(uint64_t incomingFaceId)
Definition:
tags.cpp:54
ndn::lp::LocalControlHeaderFacade::setNextHopFaceId
void setNextHopFaceId(uint64_t nextHopFaceId)
Definition:
tags.cpp:82
ndn::lp::LocalControlHeaderFacade::hasCachingPolicy
bool hasCachingPolicy() const
Definition:
tags.cpp:94
ndn::lp
Definition:
cache-policy.cpp:27
ndn::lp::LocalControlHeaderFacade::INVALID_POLICY
Definition:
tags.hpp:93
ndn::nfd::INVALID_FACE_ID
static const uint64_t INVALID_FACE_ID
Definition:
nfd-constants.hpp:30
ndnSIM
ndn-cxx
src
lp
tags.cpp
Generated on Sat Nov 12 2016 16:02:52 for ndnSIM by
1.8.12