IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
CompressedPayloadBlock.h
Go to the documentation of this file.
1
/*
2
* CompressedPayloadBlock.h
3
*
4
* Copyright (C) 2011 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
#include <
ibrdtn/data/Block.h
>
23
#include <
ibrdtn/data/Number.h
>
24
#include <
ibrdtn/data/ExtensionBlock.h
>
25
#include "
ibrdtn/data/Bundle.h
"
26
27
#ifndef COMPRESSEDPAYLOADBLOCK_H_
28
#define COMPRESSEDPAYLOADBLOCK_H_
29
30
namespace
dtn
31
{
32
namespace
data
33
{
34
class
CompressedPayloadBlock
:
public
dtn::data::Block
35
{
36
public
:
37
class
Factory
:
public
dtn::data::ExtensionBlock::Factory
38
{
39
public
:
40
Factory
() : dtn::data::
ExtensionBlock
::
Factory
(
CompressedPayloadBlock
::
BLOCK_TYPE
) {};
41
virtual
~Factory
() {};
42
virtual
dtn::data::Block
*
create
();
43
};
44
45
static
const
dtn::data::block_t
BLOCK_TYPE
;
46
47
enum
COMPRESS_ALGS
48
{
49
COMPRESSION_UNKNOWN
= 0,
50
COMPRESSION_ZLIB
= 1,
51
COMPRESSION_BZ2
= 2
52
};
53
54
CompressedPayloadBlock
();
55
virtual
~CompressedPayloadBlock
();
56
57
virtual
Length
getLength
()
const
;
58
virtual
std::ostream &
serialize
(std::ostream &stream,
Length
&length)
const
;
59
virtual
std::istream &
deserialize
(std::istream &stream,
const
Length
&length);
60
61
void
setAlgorithm
(
COMPRESS_ALGS
alg);
62
COMPRESS_ALGS
getAlgorithm
()
const
;
63
64
void
setOriginSize
(
const
Number
&s);
65
const
Number
&
getOriginSize
()
const
;
66
67
static
void
compress
(
dtn::data::Bundle
&b,
COMPRESS_ALGS
alg);
68
static
void
extract
(
dtn::data::Bundle
&b);
69
70
private
:
71
static
void
compress
(
CompressedPayloadBlock::COMPRESS_ALGS
alg, std::istream &is, std::ostream &os);
72
static
void
extract
(
CompressedPayloadBlock::COMPRESS_ALGS
alg, std::istream &is, std::ostream &os);
73
74
dtn::data::Number
_algorithm;
75
dtn::data::Number
_origin_size;
76
};
77
81
static
CompressedPayloadBlock::Factory __CompressedPayloadBlockFactory__;
82
}
83
}
84
85
#endif
/* COMPRESSEDPAYLOADBLOCK_H_ */
ibrdtn
ibrdtn
data
CompressedPayloadBlock.h
Generated on Thu Mar 27 2014 09:26:21 for IBR-DTNSuite by
1.8.4