NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
transform-base.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2017 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_SECURITY_TRANSFORM_BASE_HPP
23
#define NDN_CXX_SECURITY_TRANSFORM_BASE_HPP
24
25
#include "../../common.hpp"
26
#include <vector>
27
28
namespace
ndn
{
29
namespace
security
{
30
namespace
transform
{
31
47
class
Error
:
public
std::runtime_error
48
{
49
public
:
50
Error
(
size_t
index,
const
std::string& what);
51
52
size_t
53
getIndex
()
const
54
{
55
return
m_index;
56
}
57
58
private
:
59
size_t
m_index;
60
};
61
67
class
Downstream
68
{
69
public
:
70
virtual
71
~
Downstream
() =
default
;
72
89
size_t
90
write(
const
uint8_t* buf,
size_t
size);
91
100
void
101
end();
102
106
bool
107
isEnd
()
const
108
{
109
return
m_isEnd;
110
}
111
115
void
116
setIndex
(
size_t
index)
117
{
118
m_index = index;
119
}
120
124
size_t
125
getIndex
()
const
126
{
127
return
m_index;
128
}
129
130
protected
:
131
Downstream
();
132
133
private
:
137
virtual
size_t
138
doWrite(
const
uint8_t* buf,
size_t
size) = 0;
139
143
virtual
void
144
doEnd() = 0;
145
146
private
:
147
bool
m_isEnd;
148
size_t
m_index;
149
};
150
156
class
Upstream
157
{
158
public
:
159
virtual
160
~
Upstream
() =
default
;
161
162
protected
:
163
Upstream
();
164
165
protected
:
169
void
170
appendChain(unique_ptr<Downstream> tail);
171
172
Downstream
*
173
getNext
()
174
{
175
return
m_next.get();
176
}
177
178
protected
:
179
unique_ptr<Downstream>
m_next
;
180
};
181
185
class
Transform
:
public
Upstream
,
186
public
Downstream
,
187
noncopyable
188
{
189
protected
:
190
typedef
std::vector<uint8_t>
OBuffer
;
191
192
Transform
();
193
199
void
200
flushOutputBuffer();
201
206
void
207
flushAllOutput();
208
212
void
213
setOutputBuffer(unique_ptr<OBuffer> buffer);
214
218
bool
219
isOutputBufferEmpty()
const
;
220
221
private
:
225
size_t
226
doWrite(
const
uint8_t* data,
size_t
dataLen)
final
;
227
233
void
234
doEnd() final;
235
247
virtual
void
248
preTransform();
249
255
virtual
size_t
256
convert(const uint8_t* data,
size_t
dataLen) = 0;
257
265
virtual
void
266
finalize();
267
268
private:
269
unique_ptr<OBuffer> m_oBuffer;
270
size_t
m_outputOffset;
271
};
272
278
class
Sink
: public
Downstream
,
279
noncopyable
280
{
281
};
282
288
class
Source
:
public
Upstream
,
289
noncopyable
290
{
291
public
:
295
Source
&
296
operator>>
(unique_ptr<Transform>
transform
);
297
303
void
304
operator>>
(unique_ptr<Sink> sink);
305
306
protected
:
307
Source
();
308
312
void
313
pump();
314
318
size_t
319
getIndex
()
const
320
{
321
return
0;
322
}
323
324
private
:
328
virtual
void
329
doPump() = 0;
330
331
private
:
332
size_t
m_nModules;
// count of modules in the chain starting from this Source
333
};
334
335
}
// namespace transform
336
}
// namespace security
337
}
// namespace ndn
338
339
#endif // NDN_CXX_SECURITY_TRANSFORM_BASE_HPP
ndn::security::transform::Error::Error
Error(size_t index, const std::string &what)
Definition:
transform-base.cpp:28
ndn::security::transform::Error::getIndex
size_t getIndex() const
Definition:
transform-base.hpp:53
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::security::transform::Upstream::getNext
Downstream * getNext()
Definition:
transform-base.hpp:173
ndn::security::transform::Source::getIndex
size_t getIndex() const
Get the source module index (should always be 0).
Definition:
transform-base.hpp:319
ndn::security::transform::Sink
Abstraction of the transformation sink module.
Definition:
transform-base.hpp:278
ndn::security::transform::Transform::OBuffer
std::vector< uint8_t > OBuffer
Definition:
transform-base.hpp:190
websocketpp::transport::asio::socket::error::security
Catch-all error for security policy errors that don't fit in other categories.
Definition:
base.hpp:79
ndn::security::transform::Downstream::setIndex
void setIndex(size_t index)
Set the module index.
Definition:
transform-base.hpp:116
ndn::security::transform::Upstream
The upstream interface of a transformation module.
Definition:
transform-base.hpp:156
ndn::security::transform::Upstream::m_next
unique_ptr< Downstream > m_next
Definition:
transform-base.hpp:179
ndn::operator>>
std::istream & operator>>(std::istream &is, Name &name)
Parse URI from stream as Name.
Definition:
name.cpp:324
ndn::security::transform::Error
Base class of transformation error.
Definition:
transform-base.hpp:47
transform
ndn::security::transform::Transform
Abstraction of an intermediate transformation module.
Definition:
transform-base.hpp:185
ndn::security::transform::Downstream
The downstream interface of a transformation module.
Definition:
transform-base.hpp:67
ndn::security::transform::Downstream::isEnd
bool isEnd() const
Check if the input interface of a module is closed.
Definition:
transform-base.hpp:107
ndn::security::transform::Source
Abstraction of the transformation source module.
Definition:
transform-base.hpp:288
ndn::security::transform::Downstream::getIndex
size_t getIndex() const
Get the module index.
Definition:
transform-base.hpp:125
ndnSIM
ndn-cxx
src
security
transform
transform-base.hpp
Generated on Thu Nov 2 2017 03:30:28 for ndnSIM by
1.8.11