IBR-DTNSuite  0.10
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>
25 #include "ibrdtn/data/Bundle.h"
26 
27 #ifndef COMPRESSEDPAYLOADBLOCK_H_
28 #define COMPRESSEDPAYLOADBLOCK_H_
29 
30 namespace dtn
31 {
32  namespace data
33  {
35  {
36  public:
38  {
39  public:
41  virtual ~Factory() {};
42  virtual dtn::data::Block* create();
43  };
44 
46 
48  {
52  };
53 
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);
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_ */