I3IdentifierStack Class Reference

#include <I3IdentifierStack.h>

List of all members.


Detailed Description

Author:
Antonio Zea

Stack of I3SubIdentifier, implementing the "identifier stack" proposed in Internet Indirection Infrastructure

Public Member Functions

void push (const I3Identifier &id)
 Pushes an I3Identifier.
void push (const I3IPAddress &ip)
 Pushes an I3IPAddress.
void push (const IPvXAddress &add, int port)
 Pushes an IP address with port.
void push (const I3IdentifierStack &stack)
 Appends an I3IdentifierStack at the end.
I3SubIdentifierpeek ()
 Returns a reference to the top of the stack.
const I3SubIdentifierpeek () const
 Returns a const reference to the top of the stack.
void pop ()
 Pops a subidentifier from the top of the stack.
void clear ()
uint size () const
 Returns the size of the stack.
int compareTo (const I3IdentifierStack &s) const
 Comparation function.
int length () const
void replaceAddress (const I3IPAddress &source, const I3IPAddress &dest)

Protected Attributes

std::list
< I3SubIdentifier
stack
 Stack of subidentifiers.

Friends

std::ostream & operator<< (std::ostream &os, const I3IdentifierStack &t)


Member Function Documentation

void I3IdentifierStack::push ( const I3Identifier id  ) 

Pushes an I3Identifier.

Parameters:
id Identifier to be pushed
00026 {
00027     I3SubIdentifier id;
00028 
00029     id.setIdentifier(identifier);
00030     stack.push_back(id);
00031 }

void I3IdentifierStack::push ( const I3IPAddress ip  ) 

Pushes an I3IPAddress.

Parameters:
ip IP address to be pushed
00043 {
00044     I3SubIdentifier id;
00045 
00046     id.setIPAddress(ip);
00047     stack.push_back(id);
00048 }

void I3IdentifierStack::push ( const IPvXAddress &  add,
int  port 
)

Pushes an IP address with port.

Parameters:
add IP address to be pushed
port Address port to be pushed
00034 {
00035     I3IPAddress ipAddress;
00036 
00037     ipAddress.ip = ip;
00038     ipAddress.port = port;
00039     push(ipAddress);
00040 }

void I3IdentifierStack::push ( const I3IdentifierStack stack  ) 

Appends an I3IdentifierStack at the end.

Parameters:
stack Identifier stack to be appended
00051 {
00052     list<I3SubIdentifier>::const_iterator it;
00053 
00054     for (it = s.stack.begin(); it != s.stack.end(); it++) {
00055         stack.push_back(*it);
00056     }
00057 }

I3SubIdentifier & I3IdentifierStack::peek (  ) 

Returns a reference to the top of the stack.

00060 {
00061     return stack.back();
00062 }

const I3SubIdentifier & I3IdentifierStack::peek (  )  const

Returns a const reference to the top of the stack.

00065 {
00066     return stack.back();
00067 }

void I3IdentifierStack::pop (  ) 

Pops a subidentifier from the top of the stack.

00070 {
00071     stack.pop_back();
00072 }

void I3IdentifierStack::clear (  ) 

00097 {
00098     stack.clear();
00099 }

uint I3IdentifierStack::size (  )  const

Returns the size of the stack.

00102 {
00103     return stack.size();
00104 }

int I3IdentifierStack::compareTo ( const I3IdentifierStack s  )  const

Comparation function.

Parameters:
s Stack to be compared against
00076 {
00077     int cmp;
00078 
00079     if (stack.size() != s.size()) {
00080         return stack.size() - s.size();
00081     }
00082 
00083     list<I3SubIdentifier>::const_iterator it0 = stack.begin();
00084     list<I3SubIdentifier>::const_iterator it1 = s.stack.begin();
00085 
00086     for (; it0 != stack.end(); it0++, it1++) {
00087         //for (uint i = 0; i < stack.size(); i++) {
00088         cmp = it0->compareTo(*it1);
00089         //cmp = stack[i].compareTo(s.stack[i]);
00090         if (cmp != 0) return cmp;
00091     }
00092     return 0;
00093 }

int I3IdentifierStack::length (  )  const

00106                                     {
00107     int len = 0;
00108     list<I3SubIdentifier>::const_iterator it;
00109 
00110     for (it = stack.begin(); it != stack.end(); it++) {
00111         len += it->length();
00112     }
00113     return len + 16; /* the size variable */
00114 }

void I3IdentifierStack::replaceAddress ( const I3IPAddress source,
const I3IPAddress dest 
)

00116                                                                                          {
00117     list<I3SubIdentifier>::iterator it;
00118 
00119     for (it = stack.begin(); it != stack.end(); it++) {
00120         if (it->getType() == I3SubIdentifier::IPAddress && it->getIPAddress() == source) {
00121             it->setIPAddress(dest);
00122         }
00123     }
00124 
00125 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const I3IdentifierStack t 
) [friend]

00127                                                                    {
00128     list<I3SubIdentifier>::const_iterator it;
00129 
00130     for (it = s.stack.begin(); it != s.stack.end(); it++) {
00131         os << *it << ", ";
00132     }
00133     return os;
00134 }


Member Data Documentation

std::list<I3SubIdentifier> I3IdentifierStack::stack [protected]

Stack of subidentifiers.


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:29 2008 for ITM OverSim by  doxygen 1.5.3