NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
concepts.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2014-2018 Regents of the University of California,
4
* Arizona Board of Regents,
5
* Colorado State University,
6
* University Pierre & Marie Curie, Sorbonne University,
7
* Washington University in St. Louis,
8
* Beijing Institute of Technology,
9
* The University of Memphis.
10
*
11
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
12
*
13
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
14
* terms of the GNU Lesser General Public License as published by the Free Software
15
* Foundation, either version 3 of the License, or (at your option) any later version.
16
*
17
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
18
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
20
*
21
* You should have received copies of the GNU General Public License and GNU Lesser
22
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
23
* <http://www.gnu.org/licenses/>.
24
*
25
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
26
*/
27
28
#ifndef NDN_UTIL_CONCEPTS_HPP
29
#define NDN_UTIL_CONCEPTS_HPP
30
31
#include "
ndn-cxx/encoding/block.hpp
"
32
#include "
ndn-cxx/encoding/encoding-buffer.hpp
"
33
34
#include <boost/concept/usage.hpp>
35
#include <boost/type_traits/has_equal_to.hpp>
36
#include <boost/type_traits/has_not_equal_to.hpp>
37
#include <boost/type_traits/has_left_shift.hpp>
38
39
namespace
ndn
{
40
43
template
<
class
X>
44
class
WireEncodable
45
{
46
public
:
47
BOOST_CONCEPT_USAGE
(
WireEncodable
)
48
{
49
Block
block = j.wireEncode();
50
block.
size
();
// avoid 'unused variable block'
51
}
52
53
private
:
54
X j;
55
};
56
59
template
<
class
X>
60
class
WireEncodableWithEncodingBuffer
61
{
62
public
:
63
BOOST_CONCEPT_USAGE
(
WireEncodableWithEncodingBuffer
)
64
{
65
EncodingEstimator
estimator;
66
size_t
estimatedSize = j.wireEncode(estimator);
67
68
EncodingBuffer
encoder(estimatedSize, 0);
69
j.wireEncode(encoder);
70
}
71
72
private
:
73
X j;
74
};
75
79
template
<
class
X>
80
class
WireDecodable
81
{
82
public
:
83
BOOST_CONCEPT_USAGE
(
WireDecodable
)
84
{
85
Block
block;
86
X j(block);
87
j.wireDecode(block);
88
}
89
};
90
91
namespace
detail {
92
93
template
<
class
X>
94
class
NfdMgmtProtocolStruct
:
public
WireEncodable
<X>
95
,
public
WireEncodableWithEncodingBuffer
<X>
96
,
public
WireDecodable
<X>
97
{
98
public
:
99
BOOST_CONCEPT_USAGE
(
NfdMgmtProtocolStruct
)
100
{
101
static_assert(std::is_default_constructible<X>::value,
""
);
102
static_assert(boost::has_equal_to<X, X, bool>::value,
""
);
103
static_assert(boost::has_not_equal_to<X, X, bool>::value,
""
);
104
static_assert(boost::has_left_shift<std::ostream, X, std::ostream&>::value,
""
);
105
static_assert(std::is_base_of<tlv::Error, typename X::Error>::value,
""
);
106
}
107
};
108
109
}
// namespace detail
110
114
template
<
class
X>
115
class
StatusDatasetItem
:
public
detail::NfdMgmtProtocolStruct
<X>
116
{
117
};
118
122
template
<
class
X>
123
class
NotificationStreamItem
:
public
detail::NfdMgmtProtocolStruct
<X>
124
{
125
};
126
127
// NDN_CXX_ASSERT_DEFAULT_CONSTRUCTIBLE and NDN_CXX_ASSERT_FORWARD_ITERATOR
128
// originally written as part of NFD codebase
129
130
namespace
detail {
131
132
// As of Boost 1.61.0, the internal implementation of BOOST_CONCEPT_ASSERT does not allow
133
// multiple assertions on the same line, so we have to combine multiple concepts together.
134
135
template
<
typename
T>
136
class
StlForwardIteratorConcept
:
public
boost::ForwardIterator<T>
137
,
public
boost::DefaultConstructible<T>
138
{
139
};
140
141
}
// namespace detail
142
143
// std::is_default_constructible is broken in gcc-4.8, see bug #3882
147
#define NDN_CXX_ASSERT_DEFAULT_CONSTRUCTIBLE(T) \
148
static_assert(std::is_default_constructible<T>::value, \
149
#T " must be default-constructible"); \
150
BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<T>))
151
157
#define NDN_CXX_ASSERT_FORWARD_ITERATOR(T) \
158
static_assert(std::is_default_constructible<T>::value, \
159
#T " must be default-constructible"); \
160
BOOST_CONCEPT_ASSERT((::ndn::detail::StlForwardIteratorConcept<T>))
161
162
}
// namespace ndn
163
164
#endif // NDN_UTIL_CONCEPTS_HPP
block.hpp
ndn::WireDecodable::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(WireDecodable)
Definition:
concepts.hpp:83
ndn::WireDecodable
a concept check for TLV abstraction with .wireDecode method and constructible from Block
Definition:
concepts.hpp:81
ndn::encoding::EncodingEstimator
EncodingImpl< EstimatorTag > EncodingEstimator
Definition:
encoding-buffer-fwd.hpp:39
ndn::detail::NfdMgmtProtocolStruct
Definition:
concepts.hpp:97
ndn::WireEncodable
a concept check for TLV abstraction with .wireEncode method
Definition:
concepts.hpp:45
ndn::WireEncodableWithEncodingBuffer::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(WireEncodableWithEncodingBuffer)
Definition:
concepts.hpp:63
ndn::detail::StlForwardIteratorConcept
Definition:
concepts.hpp:138
ndn::detail::NfdMgmtProtocolStruct::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(NfdMgmtProtocolStruct)
Definition:
concepts.hpp:99
ndn::WireEncodable::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(WireEncodable)
Definition:
concepts.hpp:47
ndn::Block
Represents a TLV element of NDN packet format.
Definition:
block.hpp:43
ndn::Block::size
size_t size() const
Return the size of the encoded wire, i.e.
Definition:
block.cpp:290
ndn::StatusDatasetItem
concept check for an item in a Status Dataset
Definition:
concepts.hpp:116
encoding-buffer.hpp
ndn::WireEncodableWithEncodingBuffer
a concept check for TLV abstraction with .wireEncode method
Definition:
concepts.hpp:61
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::encoding::EncodingBuffer
EncodingImpl< EncoderTag > EncodingBuffer
Definition:
encoding-buffer-fwd.hpp:38
ndn::NotificationStreamItem
concept check for an item in a Notification Stream
Definition:
concepts.hpp:124
ndnSIM
ndn-cxx
ndn-cxx
util
concepts.hpp
Generated on Mon Jun 1 2020 22:32:15 for ndnSIM by
1.8.18