//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / IE
//
//File: connectionIdentifier.cpp
//
//Version: $Revision: 1.18 $
//
//State: $State: Exp $
//
//Date: $Date: 1999/03/10 16:05:42 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Sami Raatikainen
//
//Description:
//
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 
//

#include "connectionidentifier.h"
#include "pf/error.h"

ieConnectionIdentifier :: ieConnectionIdentifier(void)
    : ieConnectionInfo(),
      _port(0),
      _VPCI(0),
      _VCI(0),
      _VPassociated(0),
      _preferred(0),
      _VPassociatedSet(false),
      _preferredSet(false)      
{
    return;
}

ieConnectionIdentifier :: ieConnectionIdentifier(
    const ieConnectionIdentifier &other_)
    : ieConnectionInfo(other_),
      _port(other_._port),
      _VPCI(other_._VPCI),
      _VCI(other_._VCI),
      _VPassociated(other_._VPassociated),
      _preferred(other_._preferred),
      _VPassociatedSet(other_._VPassociatedSet),
      _preferredSet(other_._preferredSet)
{
    return;
}

ieConnectionIdentifier :: ~ieConnectionIdentifier(void)
{
    return;
}

const ieConnectionIdentifier &ieConnectionIdentifier :: operator=(
            const ieConnectionIdentifier &other_)
{
    if (&other_ != this)
    {
        _port = other_._port;
        _VPCI = other_._VPCI;
        _VCI = other_._VCI;
        _VPassociated = other_._VPassociated;
        _preferred = other_._preferred;
        _VPassociatedSet = other_._VPassociatedSet;
        _preferredSet = other_._preferredSet;
    }
    return *this;
}       

pfIE *ieConnectionIdentifier :: clone(void) const
{
    ieConnectionIdentifier *newIe = new ieConnectionIdentifier(*this);
    return (pfIE *)newIe;
}

ieConnectionIdentifier* ieConnectionIdentifier :: narrow(pfIE *ie_)
{
    ieConnectionIdentifier *result =
        dynamic_cast<ieConnectionIdentifier*>(ie_);
    THROW_IF_DYNAMIC_CAST_FAILED(result);
    return result;
}

void ieConnectionIdentifier :: setPort(pfUlong port_)
{
    _port = port_;
    return;
}

pfUlong ieConnectionIdentifier :: getPort(void) const
{
    return _port;
}

void ieConnectionIdentifier :: setVPCI(pfUlong value_)
{
    _VPCI = value_;
    return;
}

pfUlong ieConnectionIdentifier :: getVPCI(void) const
{
    return _VPCI;
}

void ieConnectionIdentifier :: setVCI(pfUlong value_)
{
    _VCI = value_;
    return;
}

pfUlong ieConnectionIdentifier :: getVCI(void) const
{
    return _VCI;
}

void ieConnectionIdentifier :: setVPassociated(pfUlong value_)
{
    _VPassociated = value_;
    _VPassociatedSet = true;
    return;
}

pfUlong ieConnectionIdentifier :: getVPassociated(void) const
{
    return _VPassociated;
}

bool ieConnectionIdentifier :: isVPassociated(void) const
{
    return _VPassociatedSet;
}

void ieConnectionIdentifier :: setPreferred(pfUlong value_)
{
    _preferred = value_;
    _preferredSet = true;
    return;
}

pfUlong ieConnectionIdentifier :: getPreferred(void) const
{
    return _preferred;
}

bool ieConnectionIdentifier :: isPreferred(void) const
{
    return _preferredSet;
}


void ieConnectionIdentifier :: connect(ieConnectionInfo *other_,
                                       bool bidirection_)
{
    other_->connect(this, bidirection_);
    return;
}

void ieConnectionIdentifier :: connect(ieConnectionIdentifier *other_,
                                       bool bidirection_)
{
    _manager->connect(other_, this, bidirection_, _callback);
    pfConduit nullConduit;
    _callback = nullConduit;
    return;
}

void ieConnectionIdentifier :: disconnect(ieConnectionInfo *other_,
                                          bool bidirection_)
{
    other_->disconnect(this, bidirection_);
    return;
}

void ieConnectionIdentifier :: disconnect(ieConnectionIdentifier *other_,
                                          bool bidirection_)
{
    _manager->disconnect(other_, this, bidirection_);
    return;
}
