dtn::data::BundleFactory Class Reference

#include <BundleFactory.h>

List of all members.

Public Member Functions

void registerExtensionBlock (BlockFactory *f)
void unregisterExtensionBlock (BlockFactory *f)
Bundleparse (const unsigned char *data, unsigned int size) const
BundlenewBundle ()
BlockcopyBlock (const Block &block) const
unsigned int getSequenceNumber ()

Static Public Member Functions

static BundleFactorygetInstance ()
static unsigned int getDTNTime ()
static list< Bundlesplit (const Bundle &bundle, unsigned int maxsize)
static Bundleslice (const Bundle &bundle, unsigned int size, unsigned int &offset)
static Bundlecut (const Bundle &bundle, unsigned int size, unsigned int &offset)
static pair< Bundle *, Bundle * > cutAt (const Bundle &bundle, unsigned int position)
static Bundlemerge (list< Bundle > &bundles)
static Bundlemerge (const Bundle &fragment1, const Bundle &fragment2)

Private Member Functions

 BundleFactory ()
virtual ~BundleFactory ()
BlockFactorygetExtension (unsigned char type)
map< char, BlockFactory * > & getExtensions ()
BundlecreateBundle (bool fragmented=false)
NetworkFrameparsePrimaryBlock (const unsigned char *data, unsigned int size) const

Static Private Member Functions

static bool compareFragments (const Bundle &first, const Bundle &second)
static BlockgetBlock (const unsigned char *data, unsigned int size)

Private Attributes

BlockFactory m_blockfactory
map< char, BlockFactory * > m_extensions

Static Private Attributes

static unsigned int SECONDS_TILL_2000 = 946681200


Detailed Description

This is a factory class for bundle objects.

Constructor & Destructor Documentation

dtn::data::BundleFactory::BundleFactory (  )  [private]

dtn::data::BundleFactory::~BundleFactory (  )  [private, virtual]


Member Function Documentation

BundleFactory & dtn::data::BundleFactory::getInstance (  )  [static]

Returns a static instance of the BundleFactory.

Referenced by dtn::data::Bundle::Bundle(), copyBlock(), and getBlock().

void dtn::data::BundleFactory::registerExtensionBlock ( BlockFactory f  ) 

Register a BlockFactory for parsing extension blocks of a bundle.

Parameters:
[in] f Pointer to a instance of the BlockFactory.

References dtn::data::BlockFactory::getBlockType(), and m_extensions.

Referenced by BundleFactory().

void dtn::data::BundleFactory::unregisterExtensionBlock ( BlockFactory f  ) 

Removes a BlockFactory for parsing extension blocks of a bundle.

Parameters:
[in] f Pointer to a instance of the BlockFactory.

References dtn::data::BlockFactory::getBlockType(), and m_extensions.

Referenced by ~BundleFactory().

Bundle * dtn::data::BundleFactory::parse ( const unsigned char *  data,
unsigned int  size 
) const

Bundle * dtn::data::BundleFactory::newBundle (  ) 

Block * dtn::data::BundleFactory::copyBlock ( const Block block  )  const

Makes a copy of a block.

Parameters:
block The block to copy.
Returns:
A copy of the block.

References dtn::data::BlockFactory::copy(), getExtension(), getInstance(), and dtn::data::Block::getType().

Referenced by dtn::data::Bundle::Bundle().

unsigned int dtn::data::BundleFactory::getDTNTime (  )  [static]

Get the current dtn time which is the seconds since the year 2000.

Returns:
The current dtn time.

References SECONDS_TILL_2000.

Referenced by dtn::data::Bundle::isExpired(), newBundle(), and dtn::data::PayloadBlockFactory::newCustodySignalBlock().

unsigned int dtn::data::BundleFactory::getSequenceNumber (  ) 

Get a new sequence number and count up the internal counter.

Returns:
a sequence number

Referenced by newBundle().

list< Bundle > dtn::data::BundleFactory::split ( const Bundle bundle,
unsigned int  maxsize 
) [static]

Split a bundle into a list of bundle fragments.

Parameters:
[in] bundle The bundle to split.
[in] maxsize The maximum size of a fragment.
Returns:
A list of bundle fragments.

References slice().

Bundle * dtn::data::BundleFactory::slice ( const Bundle bundle,
unsigned int  size,
unsigned int &  offset 
) [static]

Bundle * dtn::data::BundleFactory::cut ( const Bundle bundle,
unsigned int  size,
unsigned int &  offset 
) [static]

Cut the payload of the bundle after a specific size and returns a fragment bundle.

Parameters:
[in] bundle The bundle to slice.
[in] size The payload size of the fragment.
[in,out] offset A offset which tells the method to start from. The offset is moved forward to the end of the fragment.
Returns:
A bundle fragment.

References dtn::data::Bundle::appendBlock(), dtn::data::APPLICATION_DATA_LENGTH, dtn::data::FRAGMENTATION_OFFSET, dtn::data::Bundle::getFrame(), dtn::data::Bundle::getInteger(), dtn::data::PayloadBlock::getLength(), dtn::data::PayloadBlock::getPayload(), dtn::data::Bundle::getPayloadBlock(), dtn::data::Bundle::getPrimaryFlags(), dtn::data::PrimaryFlags::isFragment(), dtn::data::PrimaryFlags::isFragmentationForbidden(), dtn::data::PayloadBlockFactory::newPayloadBlock(), dtn::data::Bundle::setFragment(), and dtn::data::Bundle::setInteger().

Referenced by cutAt().

pair< Bundle *, Bundle * > dtn::data::BundleFactory::cutAt ( const Bundle bundle,
unsigned int  position 
) [static]

Cut a bundle at a given position into two fragments. The position is absolutely, so you have to use a position between the borders of the payload. Otherwise a FragmentationException is thrown.

Parameters:
[in] bundle The bundle which needs to be cut at a given position.
[in] position The position for the cut in the payload of the bundle.
Returns:
a pair of two bundles. The first bundle is the first part of the bundle.

References cut(), dtn::data::Bundle::getPayloadBlock(), and dtn::data::PayloadBlock::getPayloadRange().

Bundle * dtn::data::BundleFactory::merge ( list< Bundle > &  bundles  )  [static]

Merge a list of fragments to one bundle. If not all fragments are in the given list, the algorithm try to partly merge the bundles and put the resulting fragment into the given list. Bundle-Objects which were merged are removed out of the list and deleted by this method.

Parameters:
[in,out] bundles A list of bundle objects. These bundles have to be fragments. If not, a FragmentationException is thrown.
Returns:
A non-fragmented bundle object.

References compareFragments(), dtn::data::Bundle::getPrimaryFlags(), and dtn::data::PrimaryFlags::isFragment().

Bundle * dtn::data::BundleFactory::merge ( const Bundle fragment1,
const Bundle fragment2 
) [static]

Merge two fragments to one bundle or a new fragment. If the fragments aren't bordering or overlapping a FragmentationException is thrown.

Parameters:
[in] fragment1 The first fragment. The offset of this bundle has to be smaller than the offset of the second fragment.
[in] fragment2 The second fragment. The offset of this bundle has to be bigger than the offset of the first fragment.
Returns:
A fragment if still fragments missing or a non-fragmented bundle if all fragments available.

References dtn::data::Bundle::appendBlock(), dtn::data::APPLICATION_DATA_LENGTH, dtn::data::CREATION_TIMESTAMP, dtn::data::CREATION_TIMESTAMP_SEQUENCE, dtn::data::FRAGMENTATION_OFFSET, dtn::data::Bundle::getFrame(), dtn::data::Bundle::getInteger(), dtn::data::PayloadBlock::getLength(), dtn::data::Bundle::getPayloadBlock(), dtn::data::Bundle::getPrimaryFlags(), dtn::data::Bundle::getSource(), dtn::data::PrimaryFlags::isFragment(), dtn::data::LIFETIME, dtn::data::PayloadBlockFactory::merge(), and dtn::data::Bundle::setFragment().

BlockFactory & dtn::data::BundleFactory::getExtension ( unsigned char  type  )  [private]

References m_blockfactory, and m_extensions.

Referenced by copyBlock(), and getBlock().

map< char, BlockFactory * > & dtn::data::BundleFactory::getExtensions (  )  [private]

References m_extensions.

Bundle* dtn::data::BundleFactory::createBundle ( bool  fragmented = false  )  [private]

NetworkFrame * dtn::data::BundleFactory::parsePrimaryBlock ( const unsigned char *  data,
unsigned int  size 
) const [private]

bool dtn::data::BundleFactory::compareFragments ( const Bundle first,
const Bundle second 
) [static, private]

compare method for sorting fragments

References dtn::data::FRAGMENTATION_OFFSET, and dtn::data::Bundle::getInteger().

Referenced by merge().

Block * dtn::data::BundleFactory::getBlock ( const unsigned char *  data,
unsigned int  size 
) [static, private]


Member Data Documentation

unsigned int dtn::data::BundleFactory::SECONDS_TILL_2000 = 946681200 [static, private]

Referenced by getDTNTime().

Referenced by getExtension().


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