IBR-DTNSuite
0.10
|
#include <NativeSession.h>
Public Types | |
enum | RegisterIndex { REG1 = 0, REG2 = 1 } |
Public Member Functions | |
NativeSession (NativeSessionCallback *session_cb, NativeSerializerCallback *serializer_cb) | |
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) |
Static Public Attributes | |
static const std::string | TAG = "NativeSession" |
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, IBRCOMMON_LOGGER_ENDL, and TAG.
|
virtual |
Destructor
Definition at line 56 of file NativeSession.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::RWMutex::LOCK_READWRITE, and TAG.
void dtn::api::NativeSession::addEndpoint | ( | const std::string & | suffix | ) | throw (NativeSessionException) |
Add an application endpoint suffix to the registration
Definition at line 131 of file NativeSession.cpp.
References dtn::data::EID::add(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::core::BundleCore::local, and TAG.
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 165 of file NativeSession.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and TAG.
void dtn::api::NativeSession::clear | ( | RegisterIndex | ri | ) | throw () |
Clear the local register
Definition at line 286 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 195 of file NativeSession.cpp.
References dtn::api::Registration::getSubscriptions(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, resetEndpoint(), TAG, 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 291 of file NativeSession.cpp.
References dtn::storage::BundleStorage::get(), dtn::core::BundleCore::getInstance(), dtn::core::BundleCore::getStorage(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and TAG.
void dtn::api::NativeSession::destroy | ( | ) | throw () |
Destroy this session and block until this process is done
Definition at line 68 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 276 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 250 of file NativeSession.cpp.
References dtn::api::NativeSerializer::BUNDLE_FULL, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::RWMutex::LOCK_READONLY, TAG, and ibrcommon::Exception::what().
void dtn::api::NativeSession::getInfo | ( | RegisterIndex | ri | ) | throw () |
Return the bundle skeleton in the register using the given callback
Definition at line 263 of file NativeSession.cpp.
References dtn::api::NativeSerializer::BUNDLE_INFO, ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::RWMutex::LOCK_READONLY, TAG, and ibrcommon::Exception::what().
const dtn::data::EID & dtn::api::NativeSession::getNodeEID | ( | ) | const throw () |
Returns the node EID of this device
Definition at line 76 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 210 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 234 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(), TAG, 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 220 of file NativeSession.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and TAG.
void dtn::api::NativeSession::put | ( | RegisterIndex | ri, |
const dtn::data::Bundle & | b | ||
) | throw () |
Copy the given bundle into the local register
Definition at line 317 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 323 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 370 of file NativeSession.cpp.
References dtn::data::PayloadBlock::getBLOB(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::BLOB::iostream::iostream(), and TAG.
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 412 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(), TAG, 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 148 of file NativeSession.cpp.
References dtn::data::EID::add(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::core::BundleCore::local, and TAG.
void dtn::api::NativeSession::removeRegistration | ( | const dtn::data::EID & | eid | ) | throw (NativeSessionException) |
Remove an endpoint identifier from the registration
Definition at line 180 of file NativeSession.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, and TAG.
void dtn::api::NativeSession::resetEndpoint | ( | ) | throw () |
Resets the default endpoint to the unique registration identifier
Definition at line 122 of file NativeSession.cpp.
References dtn::api::Registration::getDefaultEID(), dtn::data::EID::getString(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::api::Registration::subscribe(), TAG, 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 304 of file NativeSession.cpp.
References IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::api::Registration::processIncomingBundle(), and TAG.
void dtn::api::NativeSession::setEndpoint | ( | const std::string & | suffix | ) | throw (NativeSessionException) |
Set the default application endpoint suffix of this registration
Definition at line 102 of file NativeSession.cpp.
References dtn::data::EID::add(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, dtn::core::BundleCore::local, and TAG.
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 332 of file NativeSession.cpp.
References dtn::data::PayloadBlock::getBLOB(), IBRCOMMON_LOGGER_DEBUG_TAG, IBRCOMMON_LOGGER_ENDL, ibrcommon::BLOB::iostream::iostream(), ibrcommon::BLOB::iostream::size(), and TAG.
|
static |
Definition at line 86 of file NativeSession.h.
Referenced by addEndpoint(), addRegistration(), clearRegistration(), delivered(), get(), getInfo(), load(), NativeSession(), next(), read(), receive(), removeEndpoint(), removeRegistration(), resetEndpoint(), send(), setEndpoint(), write(), and ~NativeSession().