NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
22 #ifndef NDN_ENCODING_ESTIMATOR_HPP
23 #define NDN_ENCODING_ESTIMATOR_HPP
24 
25 #include "../common.hpp"
26 #include "block.hpp"
27 
28 namespace ndn {
29 namespace encoding {
30 
36 class Estimator
37 {
38 public: // common interface between Encoder and Estimator
44  explicit
45  Estimator(size_t totalReserve = 0, size_t reserveFromBack = 0);
46 
47  Estimator(const Estimator&) = delete;
48 
49  Estimator&
50  operator=(const Estimator&) = delete;
51 
55  size_t
56  prependByte(uint8_t value);
57 
61  size_t
62  appendByte(uint8_t value);
63 
67  size_t
68  prependByteArray(const uint8_t* array, size_t length);
69 
73  size_t
74  appendByteArray(const uint8_t* array, size_t length);
75 
79  template<class Iterator>
80  size_t
81  prependRange(Iterator first, Iterator last);
82 
86  template<class Iterator>
87  size_t
88  appendRange(Iterator first, Iterator last);
89 
94  size_t
95  prependVarNumber(uint64_t varNumber);
96 
101  size_t
102  appendVarNumber(uint64_t varNumber);
103 
108  size_t
109  prependNonNegativeInteger(uint64_t integer);
110 
115  size_t
116  appendNonNegativeInteger(uint64_t integer);
117 
121  size_t
122  prependByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize);
123 
127  size_t
128  appendByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize);
129 
133  size_t
134  prependBlock(const Block& block);
135 
139  size_t
140  appendBlock(const Block& block);
141 };
142 
143 
144 template<class Iterator>
145 inline size_t
146 Estimator::prependRange(Iterator first, Iterator last)
147 {
148  return std::distance(first, last);
149 }
150 
151 
152 template<class Iterator>
153 inline size_t
154 Estimator::appendRange(Iterator first, Iterator last)
155 {
156  return prependRange(first, last);
157 }
158 
159 } // namespace encoding
160 } // namespace ndn
161 
162 #endif // NDN_ENCODING_ESTIMATOR_HPP
size_t prependRange(Iterator first, Iterator last)
Prepend range of bytes from the range [first, last)
Definition: estimator.hpp:146
Copyright (c) 2011-2015 Regents of the University of California.
Estimator & operator=(const Estimator &)=delete
size_t prependByte(uint8_t value)
Prepend a byte.
Definition: estimator.cpp:32
size_t prependByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize)
Prepend TLV block of type type and value from buffer array of size arraySize.
Definition: estimator.cpp:105
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
size_t appendByteArray(const uint8_t *array, size_t length)
Append a byte array array of length length.
Definition: estimator.cpp:51
size_t prependByteArray(const uint8_t *array, size_t length)
Prepend a byte array array of length length.
Definition: estimator.cpp:45
size_t appendRange(Iterator first, Iterator last)
Append range of bytes from the range [first, last)
Definition: estimator.hpp:154
size_t appendByteArrayBlock(uint32_t type, const uint8_t *array, size_t arraySize)
Append TLV block of type type and value from buffer array of size arraySize.
Definition: estimator.cpp:115
size_t prependVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
Definition: estimator.cpp:57
size_t appendNonNegativeInteger(uint64_t integer)
Append non-negative integer integer of NDN TLV encoding.
Definition: estimator.cpp:98
Estimator(size_t totalReserve=0, size_t reserveFromBack=0)
Create instance of the estimator.
Definition: estimator.cpp:27
size_t prependBlock(const Block &block)
Prepend TLV block block.
Definition: estimator.cpp:122
size_t appendBlock(const Block &block)
Append TLV block block.
Definition: estimator.cpp:133
size_t appendByte(uint8_t value)
Append a byte.
Definition: estimator.cpp:38
Helper class to estimate size of TLV encoding Interface of this class (mostly) matches interface of E...
Definition: estimator.hpp:36
size_t appendVarNumber(uint64_t varNumber)
Prepend VarNumber varNumber of NDN TLV encoding.
Definition: estimator.cpp:74
size_t prependNonNegativeInteger(uint64_t integer)
Prepend non-negative integer integer of NDN TLV encoding.
Definition: estimator.cpp:81