168 lines
4.7 KiB
C++
168 lines
4.7 KiB
C++
/*
|
|
* File: Invitation.cc
|
|
* Author: jgaebler
|
|
*
|
|
* Created on July 23, 2010, 4:00 PM
|
|
*/
|
|
|
|
#include "Invitation.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Output operator
|
|
* @param s the stream to add the output information of the invitation
|
|
* @param inv the invitation to output
|
|
* @return The extended output stream.
|
|
*/
|
|
std::ostream & operator<<(std::ostream & s, const Invitation & inv) {
|
|
|
|
s << "InvitationID=" << inv.getInvitationID();
|
|
s << ", PeerID=" << inv.getInviterID();
|
|
s << ", inviterTA=" << inv.getInviterAddress();
|
|
s << ", inviterPDesc=" << inv.getInviterPeerDescription();
|
|
s << ", inviteeTA=" << inv.getInviteeAddress();
|
|
return s;
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief Constructor
|
|
*/
|
|
Invitation::Invitation() : invId(UNDEFINED_INVITATION_ID), inviter(UNDEFINED_PEER_ID) {
|
|
}
|
|
|
|
/**
|
|
* @brief Constructor
|
|
* @param aInvitationId The invitation ID to store.
|
|
* @param aInviter The inviter peer id.
|
|
* @param aInviterTa The inviter transport address.
|
|
* @param aInviterPDesc The peer description of the inviter.
|
|
* @param aInviteeTa The address of the peer to invite.
|
|
*/
|
|
Invitation::Invitation(const InvitationID & aInvitationId,
|
|
const PeerID & aInviter,
|
|
const TransportAddress & aInviterTa,
|
|
const PeerDescription & aInviterPDesc,
|
|
const TransportAddress & aInviteeTa)
|
|
: invId(aInvitationId),
|
|
inviter(aInviter),
|
|
inviterTa(aInviterTa),
|
|
inviterPDesc(aInviterPDesc),
|
|
inviteeTa(aInviteeTa) {
|
|
}
|
|
|
|
/**
|
|
* @brief Copy constructor
|
|
*/
|
|
Invitation::Invitation(const Invitation & other){
|
|
operator =(other);
|
|
}
|
|
|
|
/**
|
|
* @brief Assignment operator
|
|
* @param other The instance to assign.
|
|
* @return A reference to the local object.
|
|
*/
|
|
Invitation &
|
|
Invitation::operator=(const Invitation & other) {
|
|
|
|
if(this != &other){
|
|
|
|
invId = other.invId;
|
|
inviter = other.inviter;
|
|
inviterTa = other.inviterTa;
|
|
inviterPDesc = other.inviterPDesc;
|
|
inviteeTa = other.inviteeTa;
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
Invitation::~Invitation() {
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the invitation id.
|
|
* @return The invitation ID.
|
|
*/
|
|
const InvitationID &
|
|
Invitation::getInvitationID() const {
|
|
return invId;
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the id of the inviting peer.
|
|
* @return The id of the inviting peer.
|
|
*/
|
|
const PeerID &
|
|
Invitation::getInviterID() const {
|
|
return inviter;
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the address of the invitee peer.
|
|
* @return The invitee address.
|
|
*/
|
|
const TransportAddress &
|
|
Invitation::getInviteeAddress() const {
|
|
return inviteeTa;
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the address of the inviting peer.
|
|
* @return The inviting peer address.
|
|
*/
|
|
const TransportAddress &
|
|
Invitation::getInviterAddress() const {
|
|
return inviterTa;
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the peer description of the inviting peer.
|
|
* @return The peer description of the inviting peer.
|
|
*/
|
|
const PeerDescription &
|
|
Invitation::getInviterPeerDescription() const {
|
|
return inviterPDesc;
|
|
}
|
|
|
|
/**
|
|
* @brief Equality operator
|
|
* @param inv The invitation to compare to.
|
|
* @return True, if the given invitation equal to current instance, false otherwise.
|
|
*/
|
|
bool
|
|
Invitation::operator==(const Invitation & inv) const {
|
|
return (invId == inv.getInvitationID()) && (inviter == inv.getInviterID());
|
|
}
|
|
|
|
/**
|
|
* @brief Equality operator
|
|
* @param inv The invitation id to compare to.
|
|
* @return True, if the given invitation id equal to current instance id, false otherwise.
|
|
*/
|
|
bool
|
|
Invitation::operator==(const InvitationID & i) const {
|
|
return invId == i;
|
|
}
|
|
|
|
#if ! OMNETPP
|
|
|
|
void
|
|
Invitation::set(Archive & archive) {
|
|
|
|
archive(invId);
|
|
archive(inviter);
|
|
archive(inviterTa);
|
|
archive(inviterPDesc);
|
|
archive(inviteeTa);
|
|
}
|
|
#endif
|
|
}
|
|
}
|