blob: 1f2137917ee348515047a5c010912ee96b9090b0 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento88a0d812017-08-19 21:31:42 -04002/*
Davide Pesavento570b20d2018-07-15 21:53:14 -04003 * Copyright (c) 2013-2018 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
Alexander Afanasyev74633892015-02-08 18:08:46 -080025#include "encoding-buffer-fwd.hpp"
26#include "encoder.hpp"
27#include "estimator.hpp"
Wentao Shang77949212014-02-01 23:42:24 -080028
Wentao Shang77949212014-02-01 23:42:24 -080029namespace ndn {
Alexander Afanasyev217325b2014-02-06 15:03:28 -080030namespace encoding {
Alexander Afanasyev217325b2014-02-06 15:03:28 -080031
Wentao Shang77949212014-02-01 23:42:24 -080032/**
Davide Pesavento88a0d812017-08-19 21:31:42 -040033 * @brief EncodingImpl specialization for actual TLV encoding
Wentao Shang77949212014-02-01 23:42:24 -080034 */
Alexander Afanasyev217325b2014-02-06 15:03:28 -080035template<>
Davide Pesavento88a0d812017-08-19 21:31:42 -040036class EncodingImpl<EncoderTag> : public Encoder
Wentao Shang77949212014-02-01 23:42:24 -080037{
38public:
Alexander Afanasyev74633892015-02-08 18:08:46 -080039 explicit
susmit8b156552016-01-12 13:10:55 -070040 EncodingImpl(size_t totalReserve = MAX_NDN_PACKET_SIZE, size_t reserveFromBack = 400)
Alexander Afanasyev74633892015-02-08 18:08:46 -080041 : Encoder(totalReserve, reserveFromBack)
Wentao Shang77949212014-02-01 23:42:24 -080042 {
Wentao Shang77949212014-02-01 23:42:24 -080043 }
44
Alexander Afanasyev15151312014-02-16 00:53:51 -080045 explicit
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070046 EncodingImpl(const Block& block)
Alexander Afanasyev74633892015-02-08 18:08:46 -080047 : Encoder(block)
Alexander Afanasyev15151312014-02-16 00:53:51 -080048 {
49 }
Wentao Shang77949212014-02-01 23:42:24 -080050};
51
Alexander Afanasyev217325b2014-02-06 15:03:28 -080052/**
Davide Pesavento88a0d812017-08-19 21:31:42 -040053 * @brief EncodingImpl specialization for TLV size estimation
Alexander Afanasyev217325b2014-02-06 15:03:28 -080054 */
55template<>
Davide Pesavento88a0d812017-08-19 21:31:42 -040056class EncodingImpl<EstimatorTag> : public Estimator
Alexander Afanasyev217325b2014-02-06 15:03:28 -080057{
58public:
Alexander Afanasyev74633892015-02-08 18:08:46 -080059 explicit
60 EncodingImpl(size_t totalReserve = 0, size_t totalFromBack = 0)
Alexander Afanasyev217325b2014-02-06 15:03:28 -080061 {
62 }
Alexander Afanasyev217325b2014-02-06 15:03:28 -080063};
64
Alexander Afanasyev74633892015-02-08 18:08:46 -080065} // namespace encoding
66} // namespace ndn
Wentao Shang77949212014-02-01 23:42:24 -080067
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070068#endif // NDN_ENCODING_ENCODING_BUFFER_HPP