Utility class to facilitate converting to and from routing string (endpoint ID) and 16-bit string IDs. More...
#include <Dictionary.h>
Public Types | |
| typedef std::map< u_int16_t, std::string > | rribd |
| typedef std::map< u_int16_t, std::string >::const_iterator | const_iterator |
Public Member Functions | |
| Dictionary (const std::string &sender="", const std::string &receiver="") | |
| Default constructor. | |
| Dictionary (const Dictionary &d) | |
| Copy constructor. | |
| ~Dictionary () | |
| Destructor. | |
| u_int16_t | find (const std::string &dest_id) const |
| If dest_id is valid, returns sid; else returns INVALID_SID. | |
| const std::string & | find (u_int16_t sid) const |
| If id is valid, returns dest_id; else returns empty string. | |
| const std::string & | sender () const |
| Convenience function; sender is defined as sid == 0. | |
| const std::string & | receiver () const |
| Convenience function; receiver is defined as sid == 1. | |
| u_int16_t | insert (const std::string &dest_id) |
| Insert dest_id and return valid id upon success; else returns INVALID_SID. | |
| u_int16_t | insert (const Bundle *b) |
| Convenience wrapper that accepts const Bundle* and passes through a call to insert(const std::string&). | |
| bool | assign (const std::string &dest_id, u_int16_t sid) |
| Assign dest_id to arbitrary id (used by TLV deserialization); return true upon success, false upon collision. | |
| size_t | size () const |
| Return the number of elements in the dictionary. | |
| size_t | guess_ribd_size (size_t RASsz) const |
| Helper function for serializing, where RASsz is the sizeof(RoutingAddressString), the overhead per RIBD entry. | |
| void | clear () |
| Wipe out dictionary and prepare to deserialize new one. | |
| Dictionary & | operator= (const Dictionary &d) |
| Assignment operator. | |
| void | dump (BundleCore *core, const char *file, u_int line) const |
| Debug method for printing out internal state to log. | |
| const_iterator | begin () const |
| Iterators. | |
| const_iterator | end () const |
| Iterators. | |
Static Public Attributes | |
| static const u_int16_t | INVALID_SID = 0xffff |
| Reserve 0xffff for in-band error signal. | |
| static const std::string | NULL_STR |
| Used for in-band error signal. | |
Protected Types | |
| typedef std::map< std::string, u_int16_t, less_string > | ribd |
Protected Attributes | |
| std::string | sender_ |
| destination id of peering initiator | |
| std::string | receiver_ |
| destination id of passive peer | |
| ribd | ribd_ |
| forward lookup, dest_id to string id | |
| rribd | rribd_ |
| reverse lookup from string id to dest_id | |
Utility class to facilitate converting to and from routing string (endpoint ID) and 16-bit string IDs.
Definition at line 33 of file prophet/Dictionary.h.
| typedef std::map<u_int16_t,std::string>::const_iterator prophet::Dictionary::const_iterator |
Definition at line 38 of file prophet/Dictionary.h.
typedef std::map<std::string,u_int16_t,less_string> prophet::Dictionary::ribd [protected] |
Definition at line 143 of file prophet/Dictionary.h.
| typedef std::map<u_int16_t,std::string> prophet::Dictionary::rribd |
Definition at line 36 of file prophet/Dictionary.h.
| prophet::Dictionary::Dictionary | ( | const std::string & | sender = "", |
|
| const std::string & | receiver = "" | |||
| ) |
Default constructor.
Definition at line 26 of file prophet/Dictionary.cc.
| prophet::Dictionary::Dictionary | ( | const Dictionary & | d | ) |
Copy constructor.
Definition at line 30 of file prophet/Dictionary.cc.
| prophet::Dictionary::~Dictionary | ( | ) | [inline] |
Destructor.
Definition at line 64 of file prophet/Dictionary.h.
| bool prophet::Dictionary::assign | ( | const std::string & | dest_id, | |
| u_int16_t | sid | |||
| ) |
Assign dest_id to arbitrary id (used by TLV deserialization); return true upon success, false upon collision.
Definition at line 96 of file prophet/Dictionary.cc.
References INVALID_SID, receiver_, ribd_, rribd_, and sender_.
Referenced by prophet::RIBDTLV::deserialize(), insert(), and prophet::RIBDTLV::ribd().
| const_iterator prophet::Dictionary::begin | ( | ) | const [inline] |
Iterators.
Definition at line 105 of file prophet/Dictionary.h.
References rribd_.
Referenced by prophet::RIBDTLV::serialize().
| void prophet::Dictionary::clear | ( | ) |
Wipe out dictionary and prepare to deserialize new one.
Definition at line 154 of file prophet/Dictionary.cc.
References receiver_, ribd_, rribd_, and sender_.
Referenced by prophet::RIBDTLV::deserialize().
| void prophet::Dictionary::dump | ( | BundleCore * | core, | |
| const char * | file, | |||
| u_int | line | |||
| ) | const |
Debug method for printing out internal state to log.
Definition at line 164 of file prophet/Dictionary.cc.
References prophet::BundleCore::LOG_DEBUG, prophet::BundleCore::print_log(), receiver_, rribd_, and sender_.
Referenced by prophet::Encounter::handle_response_tlv(), prophet::Encounter::handle_rib_tlv(), prophet::Encounter::handle_ribd_tlv(), prophet::TLVCreator::response(), prophet::TLVCreator::rib(), prophet::TLVCreator::ribd(), prophet::Encounter::send_dictionary_rib(), prophet::Encounter::send_offer(), and prophet::Encounter::send_response().
| const_iterator prophet::Dictionary::end | ( | ) | const [inline] |
Iterators.
Definition at line 106 of file prophet/Dictionary.h.
References rribd_.
Referenced by prophet::RIBDTLV::serialize().
| const std::string & prophet::Dictionary::find | ( | u_int16_t | sid | ) | const |
| u_int16_t prophet::Dictionary::find | ( | const std::string & | dest_id | ) | const |
If dest_id is valid, returns sid; else returns INVALID_SID.
Definition at line 35 of file prophet/Dictionary.cc.
References INVALID_SID, receiver_, ribd_, and sender_.
Referenced by prophet::Table::assign(), prophet::BundleOffer::get_bundle_offer(), prophet::Encounter::handle_bundle_received(), prophet::Encounter::handle_response_tlv(), insert(), prophet::TLVCreator::response(), prophet::TLVCreator::rib(), prophet::TLVCreator::ribd(), and prophet::Table::update_transitive().
| size_t prophet::Dictionary::guess_ribd_size | ( | size_t | RASsz | ) | const |
Helper function for serializing, where RASsz is the sizeof(RoutingAddressString), the overhead per RIBD entry.
Definition at line 143 of file prophet/Dictionary.cc.
References FOUR_BYTE_ALIGN, and rribd_.
Referenced by prophet::RIBDTLV::RIBDTLV(), and prophet::RIBDTLV::serialize().
| u_int16_t prophet::Dictionary::insert | ( | const Bundle * | b | ) |
Convenience wrapper that accepts const Bundle* and passes through a call to insert(const std::string&).
| u_int16_t prophet::Dictionary::insert | ( | const std::string & | dest_id | ) |
Insert dest_id and return valid id upon success; else returns INVALID_SID.
Definition at line 68 of file prophet/Dictionary.cc.
References assign(), find(), INVALID_SID, and ribd_.
Referenced by prophet::TLVCreator::ribd().
| Dictionary& prophet::Dictionary::operator= | ( | const Dictionary & | d | ) | [inline] |
| const std::string& prophet::Dictionary::receiver | ( | ) | const [inline] |
Convenience function; receiver is defined as sid == 1.
Definition at line 84 of file prophet/Dictionary.h.
References receiver_.
| const std::string& prophet::Dictionary::sender | ( | ) | const [inline] |
Convenience function; sender is defined as sid == 0.
Definition at line 79 of file prophet/Dictionary.h.
References sender_.
| size_t prophet::Dictionary::size | ( | ) | const [inline] |
Return the number of elements in the dictionary.
Definition at line 112 of file prophet/Dictionary.h.
References ribd_.
const u_int16_t prophet::Dictionary::INVALID_SID = 0xffff [static] |
Reserve 0xffff for in-band error signal.
Definition at line 43 of file prophet/Dictionary.h.
Referenced by assign(), find(), prophet::BundleOffer::get_bundle_offer(), prophet::Encounter::handle_bundle_received(), insert(), prophet::TLVCreator::rib(), prophet::TLVCreator::ribd(), and prophet::Table::update_transitive().
const std::string prophet::Dictionary::NULL_STR [static] |
Used for in-band error signal.
Definition at line 48 of file prophet/Dictionary.h.
Referenced by find().
std::string prophet::Dictionary::receiver_ [protected] |
destination id of passive peer
Definition at line 146 of file prophet/Dictionary.h.
Referenced by assign(), clear(), dump(), find(), operator=(), and receiver().
ribd prophet::Dictionary::ribd_ [protected] |
forward lookup, dest_id to string id
Definition at line 147 of file prophet/Dictionary.h.
Referenced by assign(), clear(), find(), insert(), operator=(), and size().
rribd prophet::Dictionary::rribd_ [protected] |
reverse lookup from string id to dest_id
Definition at line 148 of file prophet/Dictionary.h.
Referenced by assign(), begin(), clear(), dump(), end(), find(), guess_ribd_size(), and operator=().
std::string prophet::Dictionary::sender_ [protected] |
destination id of peering initiator
Definition at line 145 of file prophet/Dictionary.h.
Referenced by assign(), clear(), dump(), find(), operator=(), and sender().
1.6.3