Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 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. |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 22 | #ifndef NDN_ENCODING_ENCODING_BUFFER_HPP |
| 23 | #define NDN_ENCODING_ENCODING_BUFFER_HPP |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 24 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 25 | #include "encoding-buffer-fwd.hpp" |
| 26 | #include "encoder.hpp" |
| 27 | #include "estimator.hpp" |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 28 | |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 29 | namespace ndn { |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 30 | namespace encoding { |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 31 | |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 32 | /** |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 33 | * @brief EncodingImpl specialization for actual TLV encoding |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 34 | */ |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 35 | template<> |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 36 | class EncodingImpl<EncoderTag> : public Encoder |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 37 | { |
| 38 | public: |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 39 | explicit |
susmit | 8b15655 | 2016-01-12 13:10:55 -0700 | [diff] [blame] | 40 | EncodingImpl(size_t totalReserve = MAX_NDN_PACKET_SIZE, size_t reserveFromBack = 400) |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 41 | : Encoder(totalReserve, reserveFromBack) |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 42 | { |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 43 | } |
| 44 | |
Alexander Afanasyev | 1515131 | 2014-02-16 00:53:51 -0800 | [diff] [blame] | 45 | explicit |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 46 | EncodingImpl(const Block& block) |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 47 | : Encoder(block) |
Alexander Afanasyev | 1515131 | 2014-02-16 00:53:51 -0800 | [diff] [blame] | 48 | { |
| 49 | } |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 52 | /** |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 53 | * @brief EncodingImpl specialization for TLV size estimation |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 54 | */ |
| 55 | template<> |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 56 | class EncodingImpl<EstimatorTag> : public Estimator |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 57 | { |
| 58 | public: |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 59 | explicit |
| 60 | EncodingImpl(size_t totalReserve = 0, size_t totalFromBack = 0) |
| 61 | : Estimator(totalReserve, totalFromBack) |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 62 | { |
| 63 | } |
Alexander Afanasyev | 217325b | 2014-02-06 15:03:28 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 66 | } // namespace encoding |
| 67 | } // namespace ndn |
Wentao Shang | 7794921 | 2014-02-01 23:42:24 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 69 | #endif // NDN_ENCODING_ENCODING_BUFFER_HPP |