OverSim
I3SubIdentifier Class Reference

A wrapper around either an I3IPAddress or an I3Identifier. More...

#include <I3SubIdentifier.h>

Public Types

enum  IdentifierType { Invalid, Identifier, IPAddress }
 Identifier type. More...

Public Member Functions

 I3SubIdentifier ()
 Constructor.
void setIPAddress (const I3IPAddress &address)
 Sets this identifier as an I3IPAddress.
void setIdentifier (const I3Identifier &id)
 Sets this identifier as an I3Identifier.
IdentifierType getType () const
 Returns the subidentifier type.
I3IPAddressgetIPAddress ()
 Returns the IP address.
I3IdentifiergetIdentifier ()
 Returns the identifier.
int compareTo (const I3SubIdentifier &) const
 Comparison function.
int length () const

Protected Attributes

IdentifierType type
 Type of subidentifier.
I3IPAddress ipAddress
 IP address referred to.
I3Identifier identifier
 Identifier referred to.

Friends

std::ostream & operator<< (std::ostream &os, const I3SubIdentifier &s)

Detailed Description

A wrapper around either an I3IPAddress or an I3Identifier.

The I3 paper proposes an identifier stack that is "a list of identifiers that takes the form (id[1], id[2], ..., id[k]) where where id[i] is either an identifier or an address." To avoid confusion, the former identifier id[i] is called an I3SubIdentifier and the latter is the normal I3Identifier.

Definition at line 37 of file I3SubIdentifier.h.

Member Enumeration Documentation

Identifier type.

Enumerator:
Invalid 
Identifier 

Type has not been set yet.

IPAddress 

Subidentifier refers to an I3Identifier.

Subidentifier refers to an I3IPAddress

Definition at line 40 of file I3SubIdentifier.h.

Constructor & Destructor Documentation

I3SubIdentifier::I3SubIdentifier ( )

Constructor.

Definition at line 28 of file I3SubIdentifier.cc.

:
{
}

Member Function Documentation

int I3SubIdentifier::compareTo ( const I3SubIdentifier id) const

Comparison function.

Definition at line 71 of file I3SubIdentifier.cc.

{
if (type != id.type) {
return type - id.type;
} else if (type == Identifier) {
} else if (type == IPAddress) {
if (ipAddress.getIp() < id.ipAddress.getIp()) return -1;
else if (ipAddress.getIp() == id.ipAddress.getIp()) return ipAddress.getPort() - id.ipAddress.getPort();
else return 1;
}
return 0;
}
I3Identifier & I3SubIdentifier::getIdentifier ( )

Returns the identifier.

Returns
Identifier referred to

Definition at line 63 of file I3SubIdentifier.cc.

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

{
if (type != Identifier) {
// error!
};
return identifier;
}
I3IPAddress & I3SubIdentifier::getIPAddress ( )

Returns the IP address.

Returns
IP address referred to

Definition at line 55 of file I3SubIdentifier.cc.

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

{
if (type != IPAddress) {
// error!
}
return ipAddress;
}
I3SubIdentifier::IdentifierType I3SubIdentifier::getType ( ) const

Returns the subidentifier type.

Returns
Subidentifier type

Definition at line 50 of file I3SubIdentifier.cc.

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

{
return type;
}
int I3SubIdentifier::length ( ) const

Definition at line 85 of file I3SubIdentifier.cc.

{
// return sizeof(type) + (type == IPAddress ? ipAddress.length() : identifier.length());
return 1 + (type == IPAddress ? ipAddress.length() : identifier.length());
}
void I3SubIdentifier::setIdentifier ( const I3Identifier id)

Sets this identifier as an I3Identifier.

Parameters
idIdentifer to set to

Definition at line 40 of file I3SubIdentifier.cc.

Referenced by I3IdentifierStack::push().

{
I3IPAddress zero; // initialized to zero
ipAddress = zero; // set to clear
identifier = id;
}
void I3SubIdentifier::setIPAddress ( const I3IPAddress address)

Sets this identifier as an I3IPAddress.

Parameters
addressIP address to set to

Definition at line 33 of file I3SubIdentifier.cc.

Referenced by I3IdentifierStack::push().

{
ipAddress = address;
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const I3SubIdentifier s 
)
friend

Definition at line 90 of file I3SubIdentifier.cc.

{
os << s.identifier;
} else {
os << s.ipAddress;
}
return os;
}

Member Data Documentation

I3Identifier I3SubIdentifier::identifier
protected

Identifier referred to.

Definition at line 90 of file I3SubIdentifier.h.

Referenced by compareTo(), getIdentifier(), length(), operator<<(), setIdentifier(), and setIPAddress().

I3IPAddress I3SubIdentifier::ipAddress
protected

IP address referred to.

Definition at line 87 of file I3SubIdentifier.h.

Referenced by compareTo(), getIPAddress(), length(), operator<<(), setIdentifier(), and setIPAddress().

IdentifierType I3SubIdentifier::type
protected

Type of subidentifier.

Definition at line 84 of file I3SubIdentifier.h.

Referenced by compareTo(), getIdentifier(), getIPAddress(), getType(), length(), operator<<(), setIdentifier(), and setIPAddress().


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