blob: 9ab9239aae2bb477e787f04d9bef7db5394365a5 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07002/**
Alexander Afanasyev74633892015-02-08 18:08:46 -08003 * Copyright (c) 2013-2015 Regents of the University of California.
Wentao Shang77949212014-02-01 23:42:24 -08004 *
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07005 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Wentao Shang77949212014-02-01 23:42:24 -08006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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 Shang77949212014-02-01 23:42:24 -080020 */
21
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070022#ifndef NDN_ENCODING_ENCODING_BUFFER_HPP
23#define NDN_ENCODING_ENCODING_BUFFER_HPP
Wentao Shang77949212014-02-01 23:42:24 -080024
25#include "../common.hpp"
Alexander Afanasyev74633892015-02-08 18:08:46 -080026#include "encoding-buffer-fwd.hpp"
27#include "encoder.hpp"
28#include "estimator.hpp"
Wentao Shang77949212014-02-01 23:42:24 -080029
Wentao Shang77949212014-02-01 23:42:24 -080030namespace ndn {
Alexander Afanasyev217325b2014-02-06 15:03:28 -080031namespace encoding {
Alexander Afanasyev217325b2014-02-06 15:03:28 -080032
Wentao Shang77949212014-02-01 23:42:24 -080033/**
Alexander Afanasyev74633892015-02-08 18:08:46 -080034 * @brief EncodingImpl specialization for real TLV encoding
Wentao Shang77949212014-02-01 23:42:24 -080035 */
Alexander Afanasyev217325b2014-02-06 15:03:28 -080036template<>
Alexander Afanasyev74633892015-02-08 18:08:46 -080037class EncodingImpl<EncoderTag> : public encoding::Encoder
Wentao Shang77949212014-02-01 23:42:24 -080038{
39public:
Alexander Afanasyev74633892015-02-08 18:08:46 -080040 explicit
susmit8b156552016-01-12 13:10:55 -070041 EncodingImpl(size_t totalReserve = MAX_NDN_PACKET_SIZE, size_t reserveFromBack = 400)
Alexander Afanasyev74633892015-02-08 18:08:46 -080042 : Encoder(totalReserve, reserveFromBack)
Wentao Shang77949212014-02-01 23:42:24 -080043 {
Wentao Shang77949212014-02-01 23:42:24 -080044 }
45
Alexander Afanasyev15151312014-02-16 00:53:51 -080046 explicit
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070047 EncodingImpl(const Block& block)
Alexander Afanasyev74633892015-02-08 18:08:46 -080048 : Encoder(block)
Alexander Afanasyev15151312014-02-16 00:53:51 -080049 {
50 }
Wentao Shang77949212014-02-01 23:42:24 -080051};
52
Alexander Afanasyev217325b2014-02-06 15:03:28 -080053/**
Alexander Afanasyev74633892015-02-08 18:08:46 -080054 * @brief EncodingImpl specialization TLV size estimation
Alexander Afanasyev217325b2014-02-06 15:03:28 -080055 */
56template<>
Alexander Afanasyev74633892015-02-08 18:08:46 -080057class EncodingImpl<EstimatorTag> : public encoding::Estimator
Alexander Afanasyev217325b2014-02-06 15:03:28 -080058{
59public:
Alexander Afanasyev74633892015-02-08 18:08:46 -080060 explicit
61 EncodingImpl(size_t totalReserve = 0, size_t totalFromBack = 0)
62 : Estimator(totalReserve, totalFromBack)
Alexander Afanasyev217325b2014-02-06 15:03:28 -080063 {
64 }
Alexander Afanasyev217325b2014-02-06 15:03:28 -080065};
66
Alexander Afanasyev74633892015-02-08 18:08:46 -080067} // namespace encoding
68} // namespace ndn
Wentao Shang77949212014-02-01 23:42:24 -080069
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070070#endif // NDN_ENCODING_ENCODING_BUFFER_HPP