IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
NativeSerializer.h
Go to the documentation of this file.
1
/*
2
* NativeSerializer.h
3
*
4
* Copyright (C) 2013 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#ifndef NATIVESERIALIZER_H_
23
#define NATIVESERIALIZER_H_
24
25
#include "
api/NativeSerializerCallback.h
"
26
#include <
ibrdtn/data/PrimaryBlock.h
>
27
#include <
ibrdtn/data/Bundle.h
>
28
#include <streambuf>
29
#include <vector>
30
#include <iostream>
31
32
namespace
dtn
33
{
34
namespace
api
35
{
36
class
NativeCallbackStream
:
public
std::basic_streambuf<char, std::char_traits<char> > {
37
public
:
38
NativeCallbackStream
(
NativeSerializerCallback
&cb);
39
virtual
~NativeCallbackStream
();
40
41
protected
:
42
virtual
int
sync
();
43
virtual
std::char_traits<char>::int_type
overflow
(std::char_traits<char>::int_type = std::char_traits<char>::eof());
44
45
private
:
46
// output buffer
47
std::vector<char> _output_buf;
48
49
NativeSerializerCallback
&_callback;
50
};
51
52
class
NativeSerializer
{
53
public
:
54
enum
DataMode
{
55
BUNDLE_HEADER
,
56
BUNDLE_FULL
,
57
BUNDLE_INFO
58
};
59
60
NativeSerializer
(
NativeSerializerCallback
&cb,
DataMode
mode);
61
virtual
~NativeSerializer
();
62
63
NativeSerializer
&
operator<<
(
const
dtn::data::Bundle
&obj);
64
65
private
:
66
NativeSerializerCallback
&_callback;
67
DataMode
_mode;
68
};
69
}
/* namespace api */
70
}
/* namespace dtn */
71
#endif
/* NATIVESERIALIZER_H_ */
daemon
src
api
NativeSerializer.h
Generated on Thu Mar 27 2014 09:26:19 for IBR-DTNSuite by
1.8.4