IBR-DTNSuite  0.8
ibrdtn/ibrdtn/data/ScopeControlHopLimitBlock.h
Go to the documentation of this file.
00001 /*
00002  * ScopeControlHopLimitBlock.h
00003  *
00004  *  Created on: 05.08.2011
00005  *      Author: morgenro
00006  */
00007 
00008 #include <ibrdtn/data/Block.h>
00009 #include <ibrdtn/data/SDNV.h>
00010 #include <ibrdtn/data/ExtensionBlock.h>
00011 
00012 #ifndef SCOPECONTROLHOPLIMITBLOCK_H_
00013 #define SCOPECONTROLHOPLIMITBLOCK_H_
00014 
00015 namespace dtn
00016 {
00017         namespace data
00018         {
00019                 class ScopeControlHopLimitBlock : public dtn::data::Block
00020                 {
00021                 public:
00022                         class Factory : public dtn::data::ExtensionBlock::Factory
00023                         {
00024                         public:
00025                                 Factory() : dtn::data::ExtensionBlock::Factory(ScopeControlHopLimitBlock::BLOCK_TYPE) {};
00026                                 virtual ~Factory() {};
00027                                 virtual dtn::data::Block* create();
00028                         };
00029 
00030                         static const char BLOCK_TYPE = 199;
00031 
00032                         ScopeControlHopLimitBlock();
00033                         virtual ~ScopeControlHopLimitBlock();
00034 
00035                         size_t getHopsToLive() const;
00036                         void increment(size_t hops = 1);
00037                         void setLimit(size_t hops);
00038 
00039                         virtual size_t getLength() const;
00040                         virtual std::ostream &serialize(std::ostream &stream, size_t &length) const;
00041                         virtual std::istream &deserialize(std::istream &stream, const size_t length);
00042 
00043                 private:
00044                         dtn::data::SDNV _count;
00045                         dtn::data::SDNV _limit;
00046                 };
00047 
00051                 static ScopeControlHopLimitBlock::Factory __ScopeControlHopLimitBlockFactory__;
00052         } /* namespace data */
00053 } /* namespace dtn */
00054 #endif /* SCOPECONTROLHOPLIMITBLOCK_H_ */