dtn::SequenceID Class Reference

A bundle SequenceID is a version vector of (EID, counter) and/or (EID, identifier) tuples. More...

#include <SequenceID.h>

List of all members.

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 Entryget_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< EntryEntryVec
 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.


Detailed Description

A bundle SequenceID is a version vector of (EID, counter) and/or (EID, identifier) tuples.

Definition at line 29 of file SequenceID.h.


Member Typedef Documentation

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.


Member Enumeration Documentation

Valid return values from compare().

Enumerator:
LT  Less than.
EQ  Equal to.
GT  Greater than.
NEQ  Incomparable.
ILL  Illegal state.

Definition at line 46 of file SequenceID.h.

Type variable for whether an entry in the vector is a counter or an unordered identifier.

Enumerator:
EMPTY 
COUNTER 
IDENTIFIER 

Definition at line 37 of file SequenceID.h.


Constructor & Destructor Documentation

dtn::SequenceID::SequenceID (  ) 

Definition at line 31 of file SequenceID.cc.


Member Function Documentation

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().

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]

Pretty printer for comp_t.

Definition at line 37 of file SequenceID.cc.

References EQ, GT, LT, and NEQ.

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]

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]

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::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::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.

References compare(), and NEQ.

bool dtn::SequenceID::operator< ( const SequenceID v  )  const [inline]

Operator overloads.

Definition at line 90 of file SequenceID.h.

References compare(), and LT.

bool dtn::SequenceID::operator<= ( const SequenceID v  )  const [inline]

Operator overloads.

Definition at line 97 of file SequenceID.h.

References compare(), EQ, and LT.

bool dtn::SequenceID::operator== ( const SequenceID v  )  const [inline]

Operator overloads.

Definition at line 92 of file SequenceID.h.

References compare(), and EQ.

bool dtn::SequenceID::operator> ( const SequenceID v  )  const [inline]

Operator overloads.

Definition at line 91 of file SequenceID.h.

References compare(), and GT.

bool dtn::SequenceID::operator>= ( const SequenceID v  )  const [inline]

Operator overloads.

Definition at line 103 of file SequenceID.h.

References compare(), EQ, and GT.

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 begin(), COUNTER, end(), and IDENTIFIER.

Referenced by dtn::TableBasedRouter::add_bundle_to_session().


Member Data Documentation

The entry vector.

Definition at line 157 of file SequenceID.h.

Referenced by add(), assign(), begin(), empty(), end(), and parse().


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

Generated on Fri Jan 30 09:43:13 2009 for DTN Reference Implementation by  doxygen 1.5.8