Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
Junxiao Shi | 4b46998 | 2015-12-03 18:20:19 +0000 | [diff] [blame^] | 28 | #include <boost/concept/assert.hpp> |
| 29 | #include <boost/concept/usage.hpp> |
Eric Newberry | 261dbc2 | 2015-07-22 23:18:18 -0700 | [diff] [blame] | 30 | #include <boost/type_traits.hpp> |
| 31 | |
| 32 | namespace ndn { |
| 33 | namespace lp { |
| 34 | |
| 35 | /** |
| 36 | * \brief indicates where a field may occur |
| 37 | */ |
| 38 | namespace field_location_tags { |
| 39 | |
| 40 | class Base |
| 41 | { |
| 42 | }; |
| 43 | |
| 44 | /** |
| 45 | * \brief a header field |
| 46 | */ |
| 47 | class Header : public Base |
| 48 | { |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * \brief the Fragment field |
| 53 | */ |
| 54 | class Fragment : public Base |
| 55 | { |
| 56 | }; |
| 57 | |
| 58 | } // namespace field_location_tags |
| 59 | |
| 60 | /** |
| 61 | * \brief concept check for fields |
| 62 | */ |
| 63 | template<class X> |
| 64 | struct Field |
| 65 | { |
| 66 | BOOST_CONCEPT_ASSERT((boost::is_base_of<field_location_tags::Base, typename X::FieldLocation>)); |
| 67 | BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<typename X::ValueType>)); |
| 68 | BOOST_CONCEPT_ASSERT((boost::CopyConstructible<typename X::ValueType>)); |
| 69 | BOOST_CONCEPT_ASSERT((boost::is_same<typename X::TlvType::value_type, uint64_t>)); |
| 70 | BOOST_CONCEPT_ASSERT((boost::is_same<typename X::IsRepeatable::value_type, bool>)); |
| 71 | BOOST_CONCEPT_USAGE(Field) |
| 72 | { |
| 73 | Block wire; |
| 74 | X j; |
| 75 | typename X::ValueType decoded = j.decode(wire); |
| 76 | EncodingBuffer enc; |
| 77 | j.encode(enc, decoded); |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | } // namespace lp |
| 82 | } // namespace ndn |
| 83 | |
Junxiao Shi | 4b46998 | 2015-12-03 18:20:19 +0000 | [diff] [blame^] | 84 | #endif // NDN_CXX_LP_FIELD_HPP |