00001 /* 00002 * Block.h 00003 * 00004 * Created on: 29.05.2009 00005 * Author: morgenro 00006 */ 00007 00008 #ifndef BLOCK_H_ 00009 #define BLOCK_H_ 00010 00011 00012 #include "ibrdtn/data/EID.h" 00013 #include "ibrdtn/data/Exceptions.h" 00014 #include "ibrdtn/data/SDNV.h" 00015 #include "ibrdtn/data/Dictionary.h" 00016 #include "ibrdtn/data/Serializer.h" 00017 #include <ibrcommon/Exceptions.h> 00018 00019 #include <string> 00020 00021 namespace dtn 00022 { 00023 namespace data 00024 { 00025 class Bundle; 00026 00027 class Block 00028 { 00029 friend class Bundle; 00030 friend class DefaultSerializer; 00031 friend class DefaultDeserializer; 00032 friend class SeparateSerializer; 00033 friend class SeparateDeserializer; 00034 00035 public: 00036 enum ProcFlags 00037 { 00038 REPLICATE_IN_EVERY_FRAGMENT = 1, // 0 - Block must be replicated in every fragment. 00039 TRANSMIT_STATUSREPORT_IF_NOT_PROCESSED = 1 << 0x01, // 1 - Transmit status report if block can't be processed. 00040 DELETE_BUNDLE_IF_NOT_PROCESSED = 1 << 0x02, // 2 - Delete bundle if block can't be processed. 00041 LAST_BLOCK = 1 << 0x03, // 3 - Last block. 00042 DISCARD_IF_NOT_PROCESSED = 1 << 0x04, // 4 - Discard block if it can't be processed. 00043 FORWARDED_WITHOUT_PROCESSED = 1 << 0x05, // 5 - Block was forwarded without being processed. 00044 BLOCK_CONTAINS_EIDS = 1 << 0x06 // 6 - Block contains an EID-reference field. 00045 }; 00046 00047 virtual ~Block(); 00048 00049 virtual void addEID(const dtn::data::EID &eid); 00050 virtual std::list<dtn::data::EID> getEIDList() const; 00051 00052 char getType() const { return _blocktype; } 00053 00054 void set(ProcFlags flag, const bool &value); 00055 bool get(ProcFlags flag) const; 00056 00057 protected: 00064 Block(char blocktype); 00065 char _blocktype; 00066 ssize_t _blocksize; 00067 std::list<dtn::data::EID> _eids; 00068 00069 virtual size_t getLength() const = 0; 00070 virtual std::ostream &serialize(std::ostream &stream) const = 0; 00071 virtual std::istream &deserialize(std::istream &stream) = 0; 00072 00073 private: 00074 size_t _procflags; 00075 }; 00076 } 00077 } 00078 00079 #endif /* BLOCK_H_ */
1.7.1