IBR-DTNSuite
0.12
|
#include <NativeSession.h>
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::EID & | getNodeEID () 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 |
Definition at line 84 of file NativeSession.h.
Enumerator | |
---|---|
REG1 | |
REG2 |
Definition at line 88 of file NativeSession.h.
dtn::api::NativeSession::NativeSession | ( | NativeSessionCallback * | session_cb, |
NativeSerializerCallback * | serializer_cb | ||
) |
Constructor of the native session
cb | A 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.
dtn::api::NativeSession::NativeSession | ( | NativeSessionCallback * | session_cb, |
NativeSerializerCallback * | serializer_cb, | ||
const std::string & | handle | ||
) |
Constructor of the native session
cb | A 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.
|
virtual |
Destructor
Definition at line 68 of file NativeSession.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and ibrcommon::RWMutex::LOCK_READWRITE.
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().
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().
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().
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().
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().
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().
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().
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().
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().
void dtn::api::NativeSession::load | ( | RegisterIndex | ri, |
const dtn::data::BundleID & | id | ||
) | |||
throw | ( | BundleNotFoundException | |
) |
Load a bundle into the local register
Definition at line 248 of file NativeSession.cpp.
References dtn::storage::BundleStorage::get(), dtn::core::BundleCore::getInstance(), dtn::core::BundleCore::getStorage(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::core::BundleCore::processBlocks(), and ibrcommon::Exception::what().
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.
ri | Index to tell which bundle register to use. |
buf | Buffer to put the data into. |
len | The size of the buf array. After the call it contains the number of bytes in the buffer. |
offset | Start 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().
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().
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().
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().
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().
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.
ri | Index to tell which bundle register to use. |
buf | Buffer to copy. |
len | The number of bytes to copy. |
offset | Start 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().