dtn::data::Bundle Class Reference

#include <Bundle.h>

List of all members.

Public Member Functions

 Bundle (NetworkFrame *frame)
 Bundle (NetworkFrame *frame, const list< Block * > blocks)
 Bundle (const Bundle &b)
virtual ~Bundle ()
bool operator== (const Bundle &other) const
bool operator!= (const Bundle &other) const
void setFragment (bool value)
unsigned char * getData () const
unsigned int getLength () const
u_int64_t getInteger (const BUNDLE_FIELDS field) const throw (InvalidFieldException, FieldDoesNotExist)
void setInteger (const BUNDLE_FIELDS field, const u_int64_t value) throw (InvalidFieldException, FieldDoesNotExist)
string getDestination () const
void setDestination (string destination)
string getSource () const
void setSource (string source)
string getReportTo () const
void setReportTo (string reportto)
string getCustodian () const
void setCustodian (string custodian)
PrimaryFlags getPrimaryFlags () const
void setPrimaryFlags (PrimaryFlags &flags)
const list< Block * > & getBlocks () const
void appendBlock (Block *block)
void insertBlock (Block *block)
void removeBlock (Block *block)
const NetworkFramegetFrame () const
void updateBlockLength ()
bool isExpired () const
string toString () const
PayloadBlockgetPayloadBlock () const
list< Block * > getBlocks (const unsigned char type) const

Private Member Functions

int getPosition (BUNDLE_FIELDS field) throw (FieldDoesNotExist, InvalidBundleData)
Dictionary getDictionary () const
void commitDictionary (const Dictionary &dict)

Private Attributes

NetworkFramem_frame
list< Block * > m_blocks


Detailed Description

create a bundle object to manage the parameter and blocks of a bundle.

Constructor & Destructor Documentation

dtn::data::Bundle::Bundle ( NetworkFrame frame  ) 

creates a new bundle object with a given NetworkFrame

Parameters:
[in] frame A NetworkFrame Object with parsed data.

dtn::data::Bundle::Bundle ( NetworkFrame frame,
const list< Block * >  blocks 
)

creates a new bundle object with a given NetworkFrame and Blocks

Parameters:
[in] frame A NetworkFrame Object with parsed data.
[in] blocks A list of block references which belongs to this bundle.

dtn::data::Bundle::Bundle ( const Bundle b  ) 

dtn::data::Bundle::~Bundle (  )  [virtual]

destructor, called if a bundle is destroyed

References m_blocks, and m_frame.


Member Function Documentation

bool dtn::data::Bundle::operator== ( const Bundle other  )  const

Compare a Bundle object to another one. A bundle is equal to another if the source, creation timestamp and the sequence number is equal.

Parameters:
[in] other The bundle to compare with this bundle.
Returns:
true, if the bundle is equal to the given one.

References dtn::data::CREATION_TIMESTAMP, dtn::data::CREATION_TIMESTAMP_SEQUENCE, getInteger(), and getSource().

bool dtn::data::Bundle::operator!= ( const Bundle other  )  const

Compare a Bundle object to another one.

See also:
operator==()
Parameters:
[in] other The bundle to compare with this bundle.
Returns:
true, if the bundle is NOT equal to the given one.

References dtn::data::CREATION_TIMESTAMP, dtn::data::CREATION_TIMESTAMP_SEQUENCE, getInteger(), and getSource().

void dtn::data::Bundle::setFragment ( bool  value  ) 

Mark a bundle as containing fragmented payload blocks. The required fields FRAGMENTATION_OFFSET and APPLICATION_DATA_LENGTH will be added or removed if necessary.

Parameters:
[in] value true, if this bundle should marked as containing fragmented payload blocks.

References dtn::data::NetworkFrame::append(), dtn::data::APPLICATION_DATA_LENGTH, dtn::data::FRAGMENTATION_OFFSET, getPrimaryFlags(), dtn::data::PrimaryFlags::isFragment(), m_frame, dtn::data::NetworkFrame::remove(), dtn::data::PrimaryFlags::setFragment(), setPrimaryFlags(), and updateBlockLength().

Referenced by dtn::data::BundleFactory::cut(), dtn::data::BundleFactory::merge(), and dtn::data::BundleFactory::slice().

unsigned char * dtn::data::Bundle::getData (  )  const

Get a data-array with a copy of the hole bundle with all trailing blocks. You need to free this array after use!

Returns:
A data-array with all bundle data.
See also:
getLength()

References dtn::data::NetworkFrame::getData(), getLength(), dtn::data::NetworkFrame::getSize(), m_blocks, and m_frame.

Referenced by dtn::core::UDPConvergenceLayer::transmit(), and dtn::core::TCPConvergenceLayer::transmit().

unsigned int dtn::data::Bundle::getLength (  )  const

u_int64_t dtn::data::Bundle::getInteger ( const BUNDLE_FIELDS  field  )  const throw (InvalidFieldException, FieldDoesNotExist)

Get a numeric value of a specific field.

Exceptions: InvalidFieldException The field doesn't contain a numeric value. FieldDoesNotExists The field doesn't exists. InvalidBundleData The data of the bundle is invalid. SDNVDecodeFailed Decoding of the SDNV failed.

Parameters:
[in] field A field out of the enumeration BUNDLE_FIELDS
Returns:
The numeric value of the field.

References dtn::data::DICTIONARY_BYTEARRAY, dtn::data::NetworkFrame::getSDNV(), m_frame, and dtn::data::VERSION.

Referenced by dtn::data::BundleFactory::compareFragments(), dtn::data::BundleFactory::cut(), dtn::core::SimpleBundleStorage::deleteDeprecated(), getCustodian(), getDestination(), getPrimaryFlags(), getReportTo(), getSource(), isExpired(), dtn::data::StatusReportBlock::match(), dtn::data::CustodySignalBlock::match(), dtn::data::BundleFactory::merge(), operator!=(), operator==(), dtn::data::StatusReportBlock::setMatch(), dtn::data::CustodySignalBlock::setMatch(), dtn::data::BundleFactory::slice(), dtn::core::SimpleBundleStorage::store(), dtn::core::SimpleBundleStorage::storeFragment(), toString(), and updateBlockLength().

void dtn::data::Bundle::setInteger ( const BUNDLE_FIELDS  field,
const u_int64_t  value 
) throw (InvalidFieldException, FieldDoesNotExist)

Set a numeric value of a specific field.

Parameters:
[in] field A field out of the enumeration BUNDLE_FIELD
[in] value The numeric value to set in the field.

References dtn::data::DICTIONARY_BYTEARRAY, m_frame, dtn::data::NetworkFrame::set(), updateBlockLength(), and dtn::data::VERSION.

Referenced by dtn::data::BundleFactory::cut(), dtn::daemon::TestApplication::reportIt(), setPrimaryFlags(), dtn::data::BundleFactory::slice(), emma::MeasurementWorker::tick(), and emma::EmmaConvergenceLayer::yell().

string dtn::data::Bundle::getDestination (  )  const

void dtn::data::Bundle::setDestination ( string  destination  ) 

string dtn::data::Bundle::getSource (  )  const

void dtn::data::Bundle::setSource ( string  source  ) 

string dtn::data::Bundle::getReportTo (  )  const

Get the reportto EID of the bundle.

Returns:
The reportto EID of the bundle.

References dtn::data::Dictionary::get(), getDictionary(), getInteger(), dtn::data::REPORTTO_SCHEME, and dtn::data::REPORTTO_SSP.

Referenced by dtn::core::BundleCore::createStatusReport().

void dtn::data::Bundle::setReportTo ( string  reportto  ) 

Set the reportto EID of the bundle.

Parameters:
[in] reportto The reportto EID to set.

References dtn::data::Dictionary::add(), commitDictionary(), getDictionary(), m_frame, dtn::data::REPORTTO_SCHEME, dtn::data::REPORTTO_SSP, and dtn::data::NetworkFrame::set().

Referenced by dtn::daemon::TestApplication::reportIt().

string dtn::data::Bundle::getCustodian (  )  const

void dtn::data::Bundle::setCustodian ( string  custodian  ) 

PrimaryFlags dtn::data::Bundle::getPrimaryFlags (  )  const

void dtn::data::Bundle::setPrimaryFlags ( PrimaryFlags flags  ) 

Set the primary flags of this bundle.

Parameters:
[in] flags PrimaryFlags objects containing the flags to set.

References dtn::data::ProcessingFlags::getValue(), dtn::data::PROCFLAGS, and setInteger().

Referenced by appendBlock(), insertBlock(), dtn::daemon::TestApplication::reportIt(), setFragment(), emma::MeasurementWorker::tick(), and emma::EmmaConvergenceLayer::yell().

const list< Block * > & dtn::data::Bundle::getBlocks (  )  const

Get a list of all blocks of this bundle.

Returns:
a list of blocks of this bundle.

References m_blocks.

Referenced by emma::EmmaConvergenceLayer::received().

void dtn::data::Bundle::appendBlock ( Block block  ) 

void dtn::data::Bundle::insertBlock ( Block block  ) 

Insert a new block in front of the first block of this bundle.

Parameters:
[in] block The block to insert.

References getPrimaryFlags(), m_blocks, dtn::data::PrimaryFlags::setAdmRecord(), and setPrimaryFlags().

void dtn::data::Bundle::removeBlock ( Block block  ) 

Remove a specific block of the bundle.

Parameters:
[in] block The pointer to the bundle to remove.

References dtn::data::Block::getBlockFlags(), dtn::data::LAST_BLOCK, m_blocks, dtn::data::Block::setBlockFlags(), and dtn::data::ProcessingFlags::setFlag().

const NetworkFrame & dtn::data::Bundle::getFrame (  )  const

Get the NetworkFrame of this bundle containing the primary block.

Returns:
The NetworkFrame of this bundle.

References m_frame.

Referenced by dtn::data::BundleFactory::cut(), dtn::data::BundleFactory::merge(), and dtn::data::BundleFactory::slice().

void dtn::data::Bundle::updateBlockLength (  ) 

bool dtn::data::Bundle::isExpired (  )  const

Determine if a bundle is expired. return true, if the bundle is expired, else false.

References dtn::data::CREATION_TIMESTAMP, dtn::data::BundleFactory::getDTNTime(), getInteger(), and dtn::data::LIFETIME.

Referenced by dtn::core::SimpleBundleStorage::deleteDeprecated(), and dtn::core::BundleRouter::getSchedule().

string dtn::data::Bundle::toString (  )  const

Create a short string to represent this bundle.

Returns:
a short string to represent this bundle.

References dtn::data::CREATION_TIMESTAMP, dtn::data::CREATION_TIMESTAMP_SEQUENCE, getDestination(), getInteger(), and getSource().

Referenced by dtn::daemon::Debugger::callbackBundleReceived(), and dtn::core::EventDebugger::raiseEvent().

PayloadBlock * dtn::data::Bundle::getPayloadBlock (  )  const

list< Block * > dtn::data::Bundle::getBlocks ( const unsigned char  type  )  const

Get a list of block with a specific block type

Returns:
a list of block objects

References dtn::data::Block::getType(), and m_blocks.

int dtn::data::Bundle::getPosition ( BUNDLE_FIELDS  field  )  throw (FieldDoesNotExist, InvalidBundleData) [private]

Get the position of a field in the raw data. The position is the number of bytes from begin of the raw data.

Exceptions: FieldDoesNotExists Field doesn't exists InvalidBundleData The bundle data is invalid.

Parameters:
[in] field A field out of the enumeration BUNDLE_FIELDS
Returns:
The numeric position of the field.

References dtn::data::NetworkFrame::getPosition(), and m_frame.

Dictionary dtn::data::Bundle::getDictionary (  )  const [private]

void dtn::data::Bundle::commitDictionary ( const Dictionary dict  )  [private]


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on Wed Mar 25 12:41:42 2009 for IBR-DTN by  doxygen 1.5.6