NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
concepts.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_UTIL_CONCEPTS_HPP
23 #define NDN_UTIL_CONCEPTS_HPP
24 
25 #include <boost/concept/usage.hpp>
26 #include "../encoding/block.hpp"
27 #include "../encoding/encoding-buffer.hpp"
28 
29 namespace ndn {
30 
33 template<class X>
35 {
36 public:
38  {
39  Block block = j.wireEncode();
40  block.size(); // avoid 'unused variable block'
41  }
42 
43 private:
44  X j;
45 };
46 
49 template<class X>
51 {
52 public:
54  {
55  EncodingEstimator estimator;
56  size_t estimatedSize = j.wireEncode(estimator);
57 
58  EncodingBuffer encoder(estimatedSize, 0);
59  j.wireEncode(encoder);
60  }
61 
62 private:
63  X j;
64 };
65 
69 template<class X>
71 {
72 public:
74  {
75  Block block;
76  X j(block);
77  j.wireDecode(block);
78  }
79 };
80 
83 template<class X>
84 class Hashable
85 {
86 public:
88  {
89  X hash;
90  uint8_t* buf = 0;
91  size_t size = hash.DigestSize();
92 
93  hash.Update(buf, size);
94  hash.Final(buf);
95  hash.Restart();
96  }
97 };
98 
99 } // namespace ndn
100 
101 #endif // NDN_UTIL_CONCEPTS_HPP
Copyright (c) 2011-2015 Regents of the University of California.
EncodingImpl< EstimatorTag > EncodingEstimator
BOOST_CONCEPT_USAGE(Hashable)
Definition: concepts.hpp:87
BOOST_CONCEPT_USAGE(WireDecodable)
Definition: concepts.hpp:73
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
a concept check for TLV abstraction with .wireEncode method
Definition: concepts.hpp:50
size_t size() const
Definition: block.cpp:504
EncodingImpl< EncoderTag > EncodingBuffer
BOOST_CONCEPT_USAGE(WireEncodable)
Definition: concepts.hpp:37
BOOST_CONCEPT_USAGE(WireEncodableWithEncodingBuffer)
Definition: concepts.hpp:53
a concept check for TLV abstraction with .wireEncode method
Definition: concepts.hpp:34
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition: concepts.hpp:70
a concept check for CryptoPP hash algorithm
Definition: concepts.hpp:84