Public Member Functions | Protected Attributes | Friends

I3IdentifierStack Class Reference

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

#include <I3IdentifierStack.h>

List of all members.

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 ()
uint32_t 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< I3SubIdentifierstack
 Stack of subidentifiers.

Friends

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

Detailed Description

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

Definition at line 33 of file I3IdentifierStack.h.


Member Function Documentation

void I3IdentifierStack::clear (  ) 

Definition at line 99 of file I3IdentifierStack.cc.

Referenced by I3Trigger::clear().

{
    stack.clear();
}

int I3IdentifierStack::compareTo ( const I3IdentifierStack s  )  const

Comparation function.

Parameters:
s Stack to be compared against

Definition at line 78 of file I3IdentifierStack.cc.

Referenced by I3Trigger::compareTo().

{
    int cmp;

    if (stack.size() != s.size()) {
        return stack.size() - s.size();
    }

    list<I3SubIdentifier>::const_iterator it0 = stack.begin();
    list<I3SubIdentifier>::const_iterator it1 = s.stack.begin();

    for (; it0 != stack.end(); it0++, it1++) {
        //for (uint i = 0; i < stack.size(); i++) {
        cmp = it0->compareTo(*it1);
        //cmp = stack[i].compareTo(s.stack[i]);
        if (cmp != 0) return cmp;
    }
    return 0;
}

int I3IdentifierStack::length (  )  const

Definition at line 109 of file I3IdentifierStack.cc.

Referenced by I3Trigger::length().

                                    {
    int len = 0;
    list<I3SubIdentifier>::const_iterator it;

    for (it = stack.begin(); it != stack.end(); it++) {
        len += it->length();
    }
    return len + 16; /* the size variable */
}

I3SubIdentifier & I3IdentifierStack::peek (  ) 

Returns a reference to the top of the stack.

Definition at line 62 of file I3IdentifierStack.cc.

Referenced by I3::handleUDPMessage(), I3BaseApp::sendPacket(), I3::sendPacket(), and I3::sendToNode().

{
    return stack.back();
}

const I3SubIdentifier & I3IdentifierStack::peek (  )  const

Returns a const reference to the top of the stack.

Definition at line 67 of file I3IdentifierStack.cc.

{
    return stack.back();
}

void I3IdentifierStack::pop (  ) 

Pops a subidentifier from the top of the stack.

Definition at line 72 of file I3IdentifierStack.cc.

Referenced by I3BaseApp::sendPacket(), I3::sendPacket(), and I3::sendToNode().

{
    stack.pop_back();
}

void I3IdentifierStack::push ( const I3Identifier id  ) 

Pushes an I3Identifier.

Parameters:
id Identifier to be pushed

Definition at line 28 of file I3IdentifierStack.cc.

Referenced by I3Composite::createMessage(), I3TRTClient::handleTimerEvent(), I3BaseApp::insertTrigger(), push(), I3BaseApp::sendPacket(), and I3::sendPacket().

{
    I3SubIdentifier id;

    id.setIdentifier(identifier);
    stack.push_back(id);
}

void I3IdentifierStack::push ( const I3IdentifierStack stack  ) 

Appends an I3IdentifierStack at the end.

Parameters:
stack Identifier stack to be appended

Definition at line 53 of file I3IdentifierStack.cc.

{
    list<I3SubIdentifier>::const_iterator it;

    for (it = s.stack.begin(); it != s.stack.end(); it++) {
        stack.push_back(*it);
    }
}

void I3IdentifierStack::push ( const I3IPAddress ip  ) 

Pushes an I3IPAddress.

Parameters:
ip IP address to be pushed

Definition at line 45 of file I3IdentifierStack.cc.

{
    I3SubIdentifier id;

    id.setIPAddress(ip);
    stack.push_back(id);
}

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

Definition at line 36 of file I3IdentifierStack.cc.

{
    I3IPAddress ipAddress;

    ipAddress.setIp(ip);
    ipAddress.setPort(port);
    push(ipAddress);
}

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

Definition at line 119 of file I3IdentifierStack.cc.

                                                                                         {
    list<I3SubIdentifier>::iterator it;

    for (it = stack.begin(); it != stack.end(); it++) {
        if (it->getType() == I3SubIdentifier::IPAddress && it->getIPAddress() == source) {
            it->setIPAddress(dest);
        }
    }

}

uint32_t I3IdentifierStack::size (  )  const

Returns the size of the stack.

Definition at line 104 of file I3IdentifierStack.cc.

Referenced by compareTo(), I3::handleUDPMessage(), I3::insertTrigger(), and I3::sendPacket().

{
    return stack.size();
}


Friends And Related Function Documentation

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

Definition at line 130 of file I3IdentifierStack.cc.

                                                                   {
    list<I3SubIdentifier>::const_iterator it;

    for (it = s.stack.begin(); it != s.stack.end(); it++) {
        os << *it << ", ";
    }
    return os;
}


Member Data Documentation

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

Stack of subidentifiers.

Definition at line 83 of file I3IdentifierStack.h.

Referenced by clear(), compareTo(), length(), operator<<(), peek(), pop(), push(), replaceAddress(), and size().


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