#include <I3IdentifierStack.h>
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. | |
I3SubIdentifier & | peek () |
Returns a reference to the top of the stack. | |
const I3SubIdentifier & | peek () 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) |
void I3IdentifierStack::push | ( | const I3Identifier & | id | ) |
Pushes an I3Identifier.
id | Identifier to be pushed |
Referenced by I3Composite::createMessage(), I3TRTClient::handleTimerEvent(), I3BaseApp::insertTrigger(), push(), and I3BaseApp::sendPacket().
00026 { 00027 I3SubIdentifier id; 00028 00029 id.setIdentifier(identifier); 00030 stack.push_back(id); 00031 }
void I3IdentifierStack::push | ( | const I3IPAddress & | ip | ) |
Pushes an I3IPAddress.
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.
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.
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.
Referenced by I3BaseApp::sendPacket(), and I3::sendPacket().
00060 { 00061 return stack.back(); 00062 }
const I3SubIdentifier & I3IdentifierStack::peek | ( | ) | const |
void I3IdentifierStack::pop | ( | ) |
Pops a subidentifier from the top of the stack.
Referenced by I3::sendPacket().
00070 { 00071 stack.pop_back(); 00072 }
void I3IdentifierStack::clear | ( | ) |
uint I3IdentifierStack::size | ( | ) | const |
Returns the size of the stack.
Referenced by compareTo(), I3::insertTrigger(), and I3::sendPacket().
00102 { 00103 return stack.size(); 00104 }
int I3IdentifierStack::compareTo | ( | const I3IdentifierStack & | s | ) | const |
Comparation function.
s | Stack to be compared against |
Referenced by I3Trigger::compareTo().
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 |
Referenced by I3Trigger::length().
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 }
std::ostream& operator<< | ( | std::ostream & | os, | |
const I3IdentifierStack & | t | |||
) | [friend] |
std::list<I3SubIdentifier> I3IdentifierStack::stack [protected] |
Stack of subidentifiers.
Referenced by clear(), compareTo(), length(), operator<<(), peek(), pop(), push(), replaceAddress(), and size().