NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
estimator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_ENCODING_ESTIMATOR_HPP
23 #define NDN_ENCODING_ESTIMATOR_HPP
24 
26 
27 namespace ndn {
28 namespace encoding {
29 
35 class Estimator : noncopyable
36 {
37 public: // common interface between Encoder and Estimator
41  constexpr size_t
42  prependByte(uint8_t) const noexcept
43  {
44  return 1;
45  }
46 
50  constexpr size_t
51  appendByte(uint8_t) const noexcept
52  {
53  return 1;
54  }
55 
59  constexpr size_t
60  prependByteArray(const uint8_t*, size_t length) const noexcept
61  {
62  return length;
63  }
64 
68  constexpr size_t
69  appendByteArray(const uint8_t*, size_t length) const noexcept
70  {
71  return length;
72  }
73 
77  template<class Iterator>
78  size_t
79  prependRange(Iterator first, Iterator last) const noexcept
80  {
81  return std::distance(first, last);
82  }
83 
87  template<class Iterator>
88  size_t
89  appendRange(Iterator first, Iterator last) const noexcept
90  {
91  return std::distance(first, last);
92  }
93 
98  size_t
99  prependVarNumber(uint64_t varNumber) const noexcept;
100 
105  size_t
106  appendVarNumber(uint64_t varNumber) const noexcept;
107 
112  size_t
113  prependNonNegativeInteger(uint64_t integer) const noexcept;
114 
119  size_t
120  appendNonNegativeInteger(uint64_t integer) const noexcept;
121 
125  size_t
126  prependByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize) const noexcept;
127 
131  size_t
132  appendByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize) const noexcept;
133 
137  size_t
138  prependBlock(const Block& block) const;
139 
143  size_t
144  appendBlock(const Block& block) const;
145 };
146 
147 } // namespace encoding
148 } // namespace ndn
149 
150 #endif // NDN_ENCODING_ESTIMATOR_HPP
constexpr size_t appendByte(uint8_t) const noexcept
Append a byte.
Definition: estimator.hpp:51
Copyright (c) 2011-2015 Regents of the University of California.
size_t prependByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize) const noexcept
Prepend TLV block of type type and value from buffer array of size arraySize.
Definition: estimator.cpp:74
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
size_t prependVarNumber(uint64_t varNumber) const noexcept
Prepend VarNumber varNumber of NDN TLV encoding.
Definition: estimator.cpp:28
size_t appendVarNumber(uint64_t varNumber) const noexcept
Prepend VarNumber varNumber of NDN TLV encoding.
Definition: estimator.cpp:45
size_t appendBlock(const Block &block) const
Append TLV block block.
Definition: estimator.cpp:101
constexpr size_t prependByte(uint8_t) const noexcept
Prepend a byte.
Definition: estimator.hpp:42
size_t appendNonNegativeInteger(uint64_t integer) const noexcept
Append non-negative integer integer of NDN TLV encoding.
Definition: estimator.cpp:68
size_t appendByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize) const noexcept
Append TLV block of type type and value from buffer array of size arraySize.
Definition: estimator.cpp:84
constexpr size_t prependByteArray(const uint8_t *, size_t length) const noexcept
Prepend a byte array array of length length.
Definition: estimator.hpp:60
Helper class to estimate size of TLV encoding Interface of this class (mostly) matches interface of E...
Definition: estimator.hpp:35
size_t prependBlock(const Block &block) const
Prepend TLV block block.
Definition: estimator.cpp:90
constexpr size_t appendByteArray(const uint8_t *, size_t length) const noexcept
Append a byte array array of length length.
Definition: estimator.hpp:69
size_t prependRange(Iterator first, Iterator last) const noexcept
Prepend range of bytes from the range [first, last)
Definition: estimator.hpp:79
size_t appendRange(Iterator first, Iterator last) const noexcept
Append range of bytes from the range [first, last)
Definition: estimator.hpp:89
size_t prependNonNegativeInteger(uint64_t integer) const noexcept
Prepend non-negative integer integer of NDN TLV encoding.
Definition: estimator.cpp:51