blob: 199fb16609bb8f9e6cd70fdf3e6176d84430777a [file] [log] [blame]
Eric Newberry261dbc22015-07-22 23:18:18 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2015 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_CXX_LP_FIELD_HPP
23#define NDN_CXX_LP_FIELD_HPP
24
25#include "../common.hpp"
26#include "../encoding/encoding-buffer.hpp"
27
28#include <boost/type_traits.hpp>
29
30namespace ndn {
31namespace lp {
32
33/**
34 * \brief indicates where a field may occur
35 */
36namespace field_location_tags {
37
38class Base
39{
40};
41
42/**
43 * \brief a header field
44 */
45class Header : public Base
46{
47};
48
49/**
50 * \brief the Fragment field
51 */
52class Fragment : public Base
53{
54};
55
56} // namespace field_location_tags
57
58/**
59 * \brief concept check for fields
60 */
61template<class X>
62struct Field
63{
64 BOOST_CONCEPT_ASSERT((boost::is_base_of<field_location_tags::Base, typename X::FieldLocation>));
65 BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<typename X::ValueType>));
66 BOOST_CONCEPT_ASSERT((boost::CopyConstructible<typename X::ValueType>));
67 BOOST_CONCEPT_ASSERT((boost::is_same<typename X::TlvType::value_type, uint64_t>));
68 BOOST_CONCEPT_ASSERT((boost::is_same<typename X::IsRepeatable::value_type, bool>));
69 BOOST_CONCEPT_USAGE(Field)
70 {
71 Block wire;
72 X j;
73 typename X::ValueType decoded = j.decode(wire);
74 EncodingBuffer enc;
75 j.encode(enc, decoded);
76 }
77};
78
79} // namespace lp
80} // namespace ndn
81
82#endif // NDN_CXX_LP_FIELD_HPP