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 00033 public: 00034 enum ProcFlags 00035 { 00036 REPLICATE_IN_EVERY_FRAGMENT = 1, // 0 - Block must be replicated in every fragment. 00037 TRANSMIT_STATUSREPORT_IF_NOT_PROCESSED = 1 << 0x01, // 1 - Transmit status report if block can't be processed. 00038 DELETE_BUNDLE_IF_NOT_PROCESSED = 1 << 0x02, // 2 - Delete bundle if block can't be processed. 00039 LAST_BLOCK = 1 << 0x03, // 3 - Last block. 00040 DISCARD_IF_NOT_PROCESSED = 1 << 0x04, // 4 - Discard block if it can't be processed. 00041 FORWARDED_WITHOUT_PROCESSED = 1 << 0x05, // 5 - Block was forwarded without being processed. 00042 BLOCK_CONTAINS_EIDS = 1 << 0x06 // 6 - Block contains an EID-reference field. 00043 }; 00044 00045 virtual ~Block(); 00046 00047 virtual void addEID(EID eid); 00048 virtual std::list<EID> getEIDList() const; 00049 00050 char getType() { return _blocktype; } 00051 00052 void set(ProcFlags flag, bool value); 00053 bool get(ProcFlags flag) const; 00054 00055 protected: 00062 Block(char blocktype); 00063 char _blocktype; 00064 ssize_t _blocksize; 00065 std::list<dtn::data::EID> _eids; 00066 00067 virtual size_t getLength() const = 0; 00068 virtual std::ostream &serialize(std::ostream &stream) const = 0; 00069 virtual std::istream &deserialize(std::istream &stream) = 0; 00070 00071 private: 00072 size_t _procflags; 00073 }; 00074 } 00075 } 00076 00077 #endif /* BLOCK_H_ */
1.5.6