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>
34
class
WireEncodable
35
{
36
public
:
37
BOOST_CONCEPT_USAGE
(
WireEncodable
)
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>
50
class
WireEncodableWithEncodingBuffer
51
{
52
public
:
53
BOOST_CONCEPT_USAGE
(
WireEncodableWithEncodingBuffer
)
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>
70
class
WireDecodable
71
{
72
public
:
73
BOOST_CONCEPT_USAGE
(
WireDecodable
)
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
:
87
BOOST_CONCEPT_USAGE
(
Hashable
)
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
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::encoding::EncodingEstimator
EncodingImpl< EstimatorTag > EncodingEstimator
Definition:
encoding-buffer-fwd.hpp:48
ndn::Hashable::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(Hashable)
Definition:
concepts.hpp:87
ndn::WireDecodable::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(WireDecodable)
Definition:
concepts.hpp:73
ndn::Block
Class representing a wire element of NDN-TLV packet format.
Definition:
block.hpp:43
ndn::WireEncodableWithEncodingBuffer
a concept check for TLV abstraction with .wireEncode method
Definition:
concepts.hpp:50
ndn::Block::size
size_t size() const
Definition:
block.cpp:504
ndn::encoding::EncodingBuffer
EncodingImpl< EncoderTag > EncodingBuffer
Definition:
encoding-buffer-fwd.hpp:45
ndn::WireEncodable::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(WireEncodable)
Definition:
concepts.hpp:37
ndn::WireEncodableWithEncodingBuffer::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(WireEncodableWithEncodingBuffer)
Definition:
concepts.hpp:53
ndn::WireEncodable
a concept check for TLV abstraction with .wireEncode method
Definition:
concepts.hpp:34
ndn::WireDecodable
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition:
concepts.hpp:70
ndn::Hashable
a concept check for CryptoPP hash algorithm
Definition:
concepts.hpp:84
ndnSIM
ndn-cxx
src
util
concepts.hpp
Generated on Sat Nov 12 2016 16:02:53 for ndnSIM by
1.8.12