IBR-DTNSuite  0.8
ibrdtn/ibrdtn/data/StreamBlock.h
Go to the documentation of this file.
00001 /*
00002  * StreamBlock.h
00003  *
00004  *  Created on: 17.11.2011
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef STREAMBLOCK_H_
00009 #define STREAMBLOCK_H_
00010 
00011 #include "ibrdtn/data/SDNV.h"
00012 #include "ibrdtn/data/Block.h"
00013 #include "ibrdtn/data/ExtensionBlock.h"
00014 
00015 namespace dtn
00016 {
00017         namespace data
00018         {
00019                 class StreamBlock : public dtn::data::Block
00020                 {
00021                 public:
00022                         class Factory : public dtn::data::ExtensionBlock::Factory
00023                         {
00024                         public:
00025                                 Factory() : dtn::data::ExtensionBlock::Factory(StreamBlock::BLOCK_TYPE) {};
00026                                 virtual ~Factory() {};
00027                                 virtual dtn::data::Block* create();
00028                         };
00029 
00030                         static const char BLOCK_TYPE = 242;
00031 
00032                         enum STREAM_FLAGS
00033                         {
00034                                 STREAM_BEGIN = 1,
00035                                 STREAM_END = 1 << 0x01
00036                         };
00037 
00038                         StreamBlock();
00039                         virtual ~StreamBlock();
00040 
00041                         virtual size_t getLength() const;
00042                         virtual std::ostream &serialize(std::ostream &stream, size_t &length) const;
00043                         virtual std::istream &deserialize(std::istream &stream, const size_t length);
00044 
00045                         void setSequenceNumber(size_t seq);
00046                         size_t getSequenceNumber() const;
00047 
00048                         void set(STREAM_FLAGS flag, const bool &value);
00049                         bool get(STREAM_FLAGS flag) const;
00050 
00051                 private:
00052                         dtn::data::SDNV _seq;
00053                         size_t _streamflags;
00054                 };
00055 
00059                 static StreamBlock::Factory __StreamBlockFactory__;
00060         } /* namespace data */
00061 } /* namespace dtn */
00062 #endif /* STREAMBLOCK_H_ */