NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
transform-base.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
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
virtual
size_t
226
doWrite(
const
uint8_t* data,
size_t
dataLen)
final
;
227
233
virtual
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
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::Sink
Abstraction of the transformation sink module.
Definition:
transform-base.hpp:278
ndn::security::transform::Downstream::getIndex
size_t getIndex() const
Get the module index.
Definition:
transform-base.hpp:125
ndn::security::transform::Transform::OBuffer
std::vector< uint8_t > OBuffer
Definition:
transform-base.hpp:190
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::security::transform::Source::getIndex
size_t getIndex() const
Get the source module index (should always be 0).
Definition:
transform-base.hpp:319
ndn::operator>>
std::istream & operator>>(std::istream &is, Name &name)
Definition:
name.cpp:358
ndn::security::transform::Error
Base class of transformation error.
Definition:
transform-base.hpp:47
ndn::security::transform::Error::getIndex
size_t getIndex() const
Definition:
transform-base.hpp:53
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::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::Source
Abstraction of the transformation source module.
Definition:
transform-base.hpp:288
security
ndnSIM
ndn-cxx
src
security
transform
transform-base.hpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13