A bundle SequenceID is a version vector of (EID, counter) and/or (EID, identifier) tuples. More...
#include <SequenceID.h>
Classes | |
struct | Entry |
An entry in the vector. More... | |
Public Types | |
enum | type_t { EMPTY = 0, COUNTER = 1, IDENTIFIER = 2 } |
Type variable for whether an entry in the vector is a counter or an unordered identifier. More... | |
enum | comp_t { LT = -1, EQ = 0, GT = 1, NEQ = 2, ILL = 999 } |
Valid return values from compare(). More... | |
Public Member Functions | |
SequenceID () | |
void | add (const EndpointID &eid, u_int64_t counter) |
Add an (EID, counter) tuple to the vector. | |
void | add (const EndpointID &eid, const std::string &identifier) |
Add an (EID, identifier) tuple to the vector. | |
u_int64_t | get_counter (const EndpointID &eid) const |
Get the counter for a particular EID. | |
std::string | get_identifier (const EndpointID &eid) const |
Get the identifier for a particular EID. | |
int | format (char *buf, size_t sz) const |
Virtual from Formatter. | |
std::string | to_str () const |
Get a string representation. | |
bool | parse (const std::string &str) |
Build a sequence id from a string representation. | |
comp_t | compare (const SequenceID &v) const |
Compare two vectors, returning a comp_t. | |
void | assign (const SequenceID &other) |
Reset the SequenceID to be a copy of the other. | |
void | update (const SequenceID &other) |
Update the sequence id to include the max of all current entries and the new one. | |
const Entry & | get_entry (const EndpointID &eid) const |
Get an entry for the given EID. | |
bool | operator< (const SequenceID &v) const |
Operator overloads. | |
bool | operator> (const SequenceID &v) const |
Operator overloads. | |
bool | operator== (const SequenceID &v) const |
Operator overloads. | |
bool | operator!= (const SequenceID &v) const |
Note! This means not comparable -NOT- not equal to. | |
bool | operator<= (const SequenceID &v) const |
Operator overloads. | |
bool | operator>= (const SequenceID &v) const |
Operator overloads. | |
Static Public Member Functions | |
static const char * | comp2str (comp_t eq) |
Pretty printer for comp_t. | |
Static Private Member Functions | |
static comp_t | compare_entries (const Entry &left, const Entry &right) |
Compare two entries. | |
static comp_t | compare_one_way (const SequenceID &lv, const SequenceID &rv, comp_t cur_state) |
Compare vectors in a single direction. | |
Private Attributes | |
EntryVec | vector_ |
The entry vector. | |
| |
typedef std::vector< Entry > | EntryVec |
Typedefs and wrappers for the entry vector and iterators. | |
typedef EntryVec::iterator | iterator |
Typedefs and wrappers for the entry vector and iterators. | |
typedef EntryVec::const_iterator | const_iterator |
Typedefs and wrappers for the entry vector and iterators. | |
bool | empty () const |
Typedefs and wrappers for the entry vector and iterators. | |
EntryVec::iterator | begin () |
Typedefs and wrappers for the entry vector and iterators. | |
EntryVec::iterator | end () |
Typedefs and wrappers for the entry vector and iterators. | |
EntryVec::const_iterator | begin () const |
Typedefs and wrappers for the entry vector and iterators. | |
EntryVec::const_iterator | end () const |
Typedefs and wrappers for the entry vector and iterators. |
A bundle SequenceID is a version vector of (EID, counter) and/or (EID, identifier) tuples.
Definition at line 29 of file SequenceID.h.
typedef EntryVec::const_iterator dtn::SequenceID::const_iterator |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 146 of file SequenceID.h.
typedef std::vector<Entry> dtn::SequenceID::EntryVec |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 144 of file SequenceID.h.
typedef EntryVec::iterator dtn::SequenceID::iterator |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 145 of file SequenceID.h.
Valid return values from compare().
Definition at line 46 of file SequenceID.h.
Type variable for whether an entry in the vector is a counter or an unordered identifier.
Definition at line 37 of file SequenceID.h.
dtn::SequenceID::SequenceID | ( | ) |
Definition at line 31 of file SequenceID.cc.
void dtn::SequenceID::add | ( | const EndpointID & | eid, | |
const std::string & | identifier | |||
) |
Add an (EID, identifier) tuple to the vector.
Definition at line 57 of file SequenceID.cc.
References vector_.
void dtn::SequenceID::add | ( | const EndpointID & | eid, | |
u_int64_t | counter | |||
) |
Add an (EID, counter) tuple to the vector.
Definition at line 50 of file SequenceID.cc.
References vector_.
Referenced by dtn::SequenceIDBlockProcessor::consume(), and update().
void dtn::SequenceID::assign | ( | const SequenceID & | other | ) |
Reset the SequenceID to be a copy of the other.
Definition at line 347 of file SequenceID.cc.
References vector_.
Referenced by dtn::TableBasedRouter::subscribe_to_session().
EntryVec::const_iterator dtn::SequenceID::begin | ( | ) | const [inline] |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 151 of file SequenceID.h.
References vector_.
EntryVec::iterator dtn::SequenceID::begin | ( | ) | [inline] |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 149 of file SequenceID.h.
References vector_.
Referenced by compare_one_way(), format(), dtn::SequenceIDBlockProcessor::generate(), get_entry(), and update().
const char * dtn::SequenceID::comp2str | ( | comp_t | eq | ) | [static] |
SequenceID::comp_t dtn::SequenceID::compare | ( | const SequenceID & | v | ) | const |
Compare two vectors, returning a comp_t.
Definition at line 219 of file SequenceID.cc.
References ASSERT, compare_one_way(), empty(), EQ, GT, ILL, LT, and NEQ.
Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().
SequenceID::comp_t dtn::SequenceID::compare_entries | ( | const Entry & | left, | |
const Entry & | right | |||
) | [static, private] |
Compare two entries.
Definition at line 298 of file SequenceID.cc.
References COUNTER, dtn::SequenceID::Entry::counter_, EMPTY, EQ, GT, IDENTIFIER, dtn::SequenceID::Entry::identifier_, LT, NEQ, and dtn::SequenceID::Entry::type_.
Referenced by compare_one_way().
SequenceID::comp_t dtn::SequenceID::compare_one_way | ( | const SequenceID & | lv, | |
const SequenceID & | rv, | |||
comp_t | cur_state | |||
) | [static, private] |
Compare vectors in a single direction.
Definition at line 257 of file SequenceID.cc.
References begin(), compare_entries(), end(), EQ, get_entry(), GT, LT, NEQ, and next_state.
Referenced by compare().
bool dtn::SequenceID::empty | ( | ) | const [inline] |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 148 of file SequenceID.h.
References vector_.
Referenced by dtn::TableBasedRouter::add_bundle_to_session(), dtn::TableBasedRouter::add_subscriber(), compare(), dtn::TableBasedRouter::get_session_for_bundle(), dtn::APIClient::handle_recv(), and dtn::SequenceIDBlockProcessor::prepare().
EntryVec::const_iterator dtn::SequenceID::end | ( | ) | const [inline] |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 152 of file SequenceID.h.
References vector_.
EntryVec::iterator dtn::SequenceID::end | ( | ) | [inline] |
Typedefs and wrappers for the entry vector and iterators.
Definition at line 150 of file SequenceID.h.
References vector_.
Referenced by compare_one_way(), format(), dtn::SequenceIDBlockProcessor::generate(), get_entry(), parse(), and update().
int dtn::SequenceID::format | ( | char * | buf, | |
size_t | sz | |||
) | const |
Virtual from Formatter.
Definition at line 92 of file SequenceID.cc.
References begin(), COUNTER, end(), and IDENTIFIER.
u_int64_t dtn::SequenceID::get_counter | ( | const EndpointID & | eid | ) | const |
Get the counter for a particular EID.
If no entry is found or the found entry is an identifier, returns 0.
Definition at line 78 of file SequenceID.cc.
References dtn::SequenceID::Entry::counter_, and get_entry().
const SequenceID::Entry & dtn::SequenceID::get_entry | ( | const EndpointID & | eid | ) | const |
Get an entry for the given EID.
If no matching entry exists in the vector, returns a static null entry with counter == 0 and identifier == ""
Definition at line 64 of file SequenceID.cc.
References begin(), and end().
Referenced by compare_one_way(), get_counter(), and get_identifier().
std::string dtn::SequenceID::get_identifier | ( | const EndpointID & | eid | ) | const |
Get the identifier for a particular EID.
If no entry is found or the found entry is a counter, returns an empty string.
Definition at line 85 of file SequenceID.cc.
References get_entry(), and dtn::SequenceID::Entry::identifier_.
bool dtn::SequenceID::operator!= | ( | const SequenceID & | v | ) | const [inline] |
Note! This means not comparable -NOT- not equal to.
Definition at line 95 of file SequenceID.h.
bool dtn::SequenceID::operator< | ( | const SequenceID & | v | ) | const [inline] |
bool dtn::SequenceID::operator<= | ( | const SequenceID & | v | ) | const [inline] |
bool dtn::SequenceID::operator== | ( | const SequenceID & | v | ) | const [inline] |
bool dtn::SequenceID::operator> | ( | const SequenceID & | v | ) | const [inline] |
bool dtn::SequenceID::operator>= | ( | const SequenceID & | v | ) | const [inline] |
bool dtn::SequenceID::parse | ( | const std::string & | str | ) |
Build a sequence id from a string representation.
If the value part contains only numeric characters, it is treated as a counter, otherwise it is treated as an identifier
Definition at line 129 of file SequenceID.cc.
References ASSERT, EAT_WS, end(), MATCH_CHAR, dtn::EndpointID::valid(), and vector_.
std::string dtn::SequenceID::to_str | ( | ) | const |
Get a string representation.
Definition at line 120 of file SequenceID.cc.
References buf.
Referenced by dtn::Bundle::format_verbose(), and dtn::APIClient::handle_recv().
void dtn::SequenceID::update | ( | const SequenceID & | other | ) |
Update the sequence id to include the max of all current entries and the new one.
Definition at line 354 of file SequenceID.cc.
References add(), begin(), COUNTER, end(), and IDENTIFIER.
Referenced by dtn::TableBasedRouter::add_bundle_to_session().
EntryVec dtn::SequenceID::vector_ [private] |