IBR-DTNSuite 0.6

ibrdtn/ibrdtn/data/MetaBundle.cpp

Go to the documentation of this file.
00001 /*
00002  * MetaBundle.cpp
00003  *
00004  *  Created on: 16.02.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef METABUNDLE_CPP_
00009 #define METABUNDLE_CPP_
00010 
00011 #include "ibrdtn/data/MetaBundle.h"
00012 #include "ibrdtn/utils/Clock.h"
00013 
00014 namespace dtn
00015 {
00016         namespace data
00017         {
00018                 MetaBundle::MetaBundle()
00019                  : BundleID(), received(), lifetime(0), destination(), reportto(),
00020                    custodian(), appdatalength(0), procflags(0), expiretime(0)
00021                 {
00022                 }
00023 
00024                 MetaBundle::MetaBundle(const dtn::data::BundleID &id, const size_t l,
00025                                 const dtn::data::DTNTime recv, const dtn::data::EID d, const dtn::data::EID r,
00026                                 const dtn::data::EID c, const size_t app, const size_t proc)
00027                  : BundleID(id), received(recv), lifetime(l), destination(d), reportto(r),
00028                    custodian(c), appdatalength(app), procflags(proc), expiretime(0)
00029                 {
00030                         expiretime = dtn::utils::Clock::getExpireTime(id.getTimestamp(), l);
00031                 }
00032 
00033                 MetaBundle::MetaBundle(const dtn::data::Bundle &b)
00034                  : BundleID(b), lifetime(b._lifetime), destination(b._destination), reportto(b._reportto),
00035                    custodian(b._custodian), appdatalength(b._appdatalength), procflags(b._procflags), expiretime(0)
00036                 {
00037                         expiretime = dtn::utils::Clock::getExpireTime(b);
00038                 }
00039 
00040                 MetaBundle::~MetaBundle()
00041                 {}
00042 
00043                 int MetaBundle::getPriority() const
00044                 {
00045                         // read priority
00046                         if (procflags & dtn::data::Bundle::PRIORITY_BIT1)
00047                         {
00048                                 return 0;
00049                         }
00050 
00051                         if (procflags & dtn::data::Bundle::PRIORITY_BIT2)
00052                         {
00053                                 return 1;
00054                         }
00055 
00056                         return -1;
00057                 }
00058 
00059                 bool MetaBundle::get(dtn::data::PrimaryBlock::FLAGS flag) const
00060                 {
00061                         return (procflags & flag);
00062                 }
00063         }
00064 }
00065 
00066 #endif /* METABUNDLE_CPP_ */