IBR-DTNSuite  0.12
dtn::api::NativeSession Class Reference

#include <NativeSession.h>

Collaboration diagram for dtn::api::NativeSession:
Collaboration graph

Public Types

enum  RegisterIndex { REG1 = 0, REG2 = 1 }
 

Public Member Functions

 NativeSession (NativeSessionCallback *session_cb, NativeSerializerCallback *serializer_cb)
 
 NativeSession (NativeSessionCallback *session_cb, NativeSerializerCallback *serializer_cb, const std::string &handle)
 
virtual ~NativeSession ()
 
void destroy () throw ()
 
const dtn::data::EIDgetNodeEID () const throw ()
 
void setEndpoint (const std::string &suffix) throw (NativeSessionException)
 
void resetEndpoint () throw ()
 
void addEndpoint (const std::string &suffix) throw (NativeSessionException)
 
void removeEndpoint (const std::string &suffix) throw (NativeSessionException)
 
void addRegistration (const dtn::data::EID &eid) throw (NativeSessionException)
 
void removeRegistration (const dtn::data::EID &eid) throw (NativeSessionException)
 
void clearRegistration () throw ()
 
std::vector< std::string > getSubscriptions () throw ()
 
void next (RegisterIndex ri) throw (BundleNotFoundException)
 
void load (RegisterIndex ri, const dtn::data::BundleID &id) throw (BundleNotFoundException)
 
void get (RegisterIndex ri) throw ()
 
void getInfo (RegisterIndex ri) throw ()
 
void free (RegisterIndex ri) throw (BundleNotFoundException)
 
void clear (RegisterIndex ri) throw ()
 
void delivered (const dtn::data::BundleID &id) const throw (BundleNotFoundException)
 
dtn::data::BundleID send (RegisterIndex ri) throw ()
 
void put (RegisterIndex ri, const dtn::data::Bundle &b) throw ()
 
void put (RegisterIndex ri, const dtn::data::PrimaryBlock &b) throw ()
 
void write (RegisterIndex ri, const char *buf, const size_t len, const size_t offset=std::string::npos) throw ()
 
void read (RegisterIndex ri, char *buf, size_t &len, const size_t offset=0) throw ()
 
void receive () throw (NativeSessionException)
 
const std::string & getHandle () const
 

Detailed Description

Definition at line 84 of file NativeSession.h.

Member Enumeration Documentation

Enumerator
REG1 
REG2 

Definition at line 88 of file NativeSession.h.

Constructor & Destructor Documentation

dtn::api::NativeSession::NativeSession ( NativeSessionCallback session_cb,
NativeSerializerCallback serializer_cb 
)

Constructor of the native session

Parameters
cbA callback object for notifications. May be NULL.

Definition at line 44 of file NativeSession.cpp.

References dtn::core::EventDispatcher< E >::add(), dtn::api::Registration::getDefaultEID(), IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.

Here is the call graph for this function:

dtn::api::NativeSession::NativeSession ( NativeSessionCallback session_cb,
NativeSerializerCallback serializer_cb,
const std::string &  handle 
)

Constructor of the native session

Parameters
cbA callback object for notifications. May be NULL.

Definition at line 56 of file NativeSession.cpp.

References dtn::core::EventDispatcher< E >::add(), dtn::api::Registration::getDefaultEID(), IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.

Here is the call graph for this function:

dtn::api::NativeSession::~NativeSession ( )
virtual

Member Function Documentation

void dtn::api::NativeSession::addEndpoint ( const std::string &  suffix)
throw (NativeSessionException
)

Add an application endpoint suffix to the registration

Definition at line 145 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::core::BundleCore::local, and dtn::data::EID::setApplication().

Here is the call graph for this function:

void dtn::api::NativeSession::addRegistration ( const dtn::data::EID eid)
throw (NativeSessionException
)

Add an endpoint identifier to the registration (commonly used for group endpoints)

Definition at line 179 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.

void dtn::api::NativeSession::clear ( RegisterIndex  ri)
throw (
)

Clear the local register

Definition at line 300 of file NativeSession.cpp.

void dtn::api::NativeSession::clearRegistration ( )
throw (
)

Removes all registrations and reset the default endpoint to the unique registration identifier

Definition at line 209 of file NativeSession.cpp.

References dtn::api::Registration::getSubscriptions(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, resetEndpoint(), and dtn::api::Registration::unsubscribe().

Here is the call graph for this function:

void dtn::api::NativeSession::delivered ( const dtn::data::BundleID id) const
throw (BundleNotFoundException
)

Mark the bundle with the given ID as delivered.

Definition at line 305 of file NativeSession.cpp.

References dtn::core::BundleCore::getInstance(), dtn::core::BundleCore::getStorage(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and dtn::storage::BundleStorage::info().

Here is the call graph for this function:

void dtn::api::NativeSession::destroy ( )
throw (
)

Destroy this session and block until this process is done

Definition at line 80 of file NativeSession.cpp.

References dtn::api::Registration::abort(), and dtn::core::EventDispatcher< E >::remove().

Here is the call graph for this function:

void dtn::api::NativeSession::free ( RegisterIndex  ri)
throw (BundleNotFoundException
)

Delete the bundle in the local register from the storage

Definition at line 290 of file NativeSession.cpp.

References dtn::core::BundleCore::getInstance(), dtn::core::BundleCore::getStorage(), and dtn::storage::BundleStorage::remove().

Here is the call graph for this function:

void dtn::api::NativeSession::get ( RegisterIndex  ri)
throw (
)

Return the bundle in the register using the given callback

Definition at line 264 of file NativeSession.cpp.

References dtn::api::NativeSerializer::BUNDLE_FULL, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::RWMutex::LOCK_READONLY, and ibrcommon::Exception::what().

Here is the call graph for this function:

const std::string & dtn::api::NativeSession::getHandle ( ) const

Return the handle of this session

Definition at line 491 of file NativeSession.cpp.

References dtn::api::Registration::getHandle().

Here is the call graph for this function:

void dtn::api::NativeSession::getInfo ( RegisterIndex  ri)
throw (
)

Return the bundle skeleton in the register using the given callback

Definition at line 277 of file NativeSession.cpp.

References dtn::api::NativeSerializer::BUNDLE_INFO, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::RWMutex::LOCK_READONLY, and ibrcommon::Exception::what().

Here is the call graph for this function:

const dtn::data::EID & dtn::api::NativeSession::getNodeEID ( ) const
throw (
)

Returns the node EID of this device

Definition at line 88 of file NativeSession.cpp.

References dtn::core::BundleCore::local.

std::vector< std::string > dtn::api::NativeSession::getSubscriptions ( )
throw (
)

Retrieve all registered endpoints

Definition at line 224 of file NativeSession.cpp.

References dtn::api::Registration::getSubscriptions().

Here is the call graph for this function:

void dtn::api::NativeSession::load ( RegisterIndex  ri,
const dtn::data::BundleID id 
)
throw (BundleNotFoundException
)
void dtn::api::NativeSession::next ( RegisterIndex  ri)
throw (BundleNotFoundException
)

Loads the next bundle in the queue into the local register

Definition at line 234 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.

void dtn::api::NativeSession::put ( RegisterIndex  ri,
const dtn::data::Bundle b 
)
throw (
)

Copy the given bundle into the local register

Definition at line 328 of file NativeSession.cpp.

void dtn::api::NativeSession::put ( RegisterIndex  ri,
const dtn::data::PrimaryBlock b 
)
throw (
)

Copy the PrimaryBlock into the local register

Definition at line 334 of file NativeSession.cpp.

void dtn::api::NativeSession::read ( RegisterIndex  ri,
char *  buf,
size_t &  len,
const size_t  offset = 0 
)
throw (
)

Read max. <len> bytes from the payload block in the bundle. If there is no payload block available the read method will set len = 0 and return. Otherwise the len variable contains the number of bytes written into buf.

Parameters
riIndex to tell which bundle register to use.
bufBuffer to put the data into.
lenThe size of the buf array. After the call it contains the number of bytes in the buffer.
offsetStart here to read.

Definition at line 381 of file NativeSession.cpp.

References dtn::data::PayloadBlock::getBLOB(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and ibrcommon::BLOB::iostream::iostream().

Here is the call graph for this function:

void dtn::api::NativeSession::receive ( )
throw (NativeSessionException
)

Receives one bundle and returns. If there is no bundle this call will block until a bundle is available or destroy() has been called.

Definition at line 423 of file NativeSession.cpp.

References dtn::data::PrimaryBlock::APPDATA_IS_ADMRECORD, dtn::api::Registration::delivered(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::Queue< T >::push(), dtn::api::Registration::receiveMetaBundle(), dtn::api::Registration::wait_for_bundle(), and ibrcommon::Exception::what().

Here is the call graph for this function:

void dtn::api::NativeSession::removeEndpoint ( const std::string &  suffix)
throw (NativeSessionException
)

Remove an application endpoint suffix from the registration

Definition at line 162 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::core::BundleCore::local, and dtn::data::EID::setApplication().

Here is the call graph for this function:

void dtn::api::NativeSession::removeRegistration ( const dtn::data::EID eid)
throw (NativeSessionException
)

Remove an endpoint identifier from the registration

Definition at line 194 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.

void dtn::api::NativeSession::resetEndpoint ( )
throw (
)

Resets the default endpoint to the unique registration identifier

Definition at line 136 of file NativeSession.cpp.

References dtn::api::Registration::getDefaultEID(), dtn::data::EID::getString(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::api::Registration::subscribe(), and dtn::api::Registration::unsubscribe().

Referenced by clearRegistration().

Here is the call graph for this function:

dtn::data::BundleID dtn::api::NativeSession::send ( RegisterIndex  ri)
throw (
)

Send the bundle in the local register

Definition at line 318 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and dtn::api::Registration::processIncomingBundle().

Here is the call graph for this function:

void dtn::api::NativeSession::setEndpoint ( const std::string &  suffix)
throw (NativeSessionException
)

Set the default application endpoint suffix of this registration

Definition at line 114 of file NativeSession.cpp.

References IBRCOMMON_LOGGER_DEBUG_TAG, and IBRCOMMON_LOGGER_ENDL.

void dtn::api::NativeSession::write ( RegisterIndex  ri,
const char *  buf,
const size_t  len,
const size_t  offset = std::string::npos 
)
throw (
)

Write byte into the payload block of the bundle in the register. If there is no payload block, this method will append a new one at the end of all blocks.

Parameters
riIndex to tell which bundle register to use.
bufBuffer to copy.
lenThe number of bytes to copy.
offsetStart here to write.

Definition at line 343 of file NativeSession.cpp.

References dtn::data::PayloadBlock::getBLOB(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::BLOB::iostream::iostream(), and ibrcommon::BLOB::iostream::size().

Here is the call graph for this function:


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