//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / SW
//
//File: swlink.cpp
//
//Version: $Revision: 1.2 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/03 10:34:07 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Timo Pärnänen
//
//Description:
//      See corresponding header file.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 

#include "swlink.h"
#include "protocol/cc/cccrossconnectormux.h"

swLink :: swLink(void)
    : _linkIdentifier(0),
      _factoryProxy(),
      _muxProxy(),
      _coOrdProxy(),
      _maxMuxKeyValue(0xFFFFFF) // TODO !!
{
    return;
}

swLink :: swLink(const swLink &other_)
    : _linkIdentifier(0),
      _factoryProxy(),
      _muxProxy(),
      _coOrdProxy(),
      _maxMuxKeyValue(other_._maxMuxKeyValue)
{
    return;
}

swLink :: ~swLink(void)
{
    _factoryProxy.disconnect(); 
    _muxProxy.disconnect();     //++TODO++ B-SIDES OF THE MUX !!!
    _coOrdProxy.disconnect();
    return;
}

pfConduit swLink :: getCoOrdConduit(void)
{
    return _coOrdProxy;
}

void swLink :: connectProtocols(void)
{
    _factoryProxy.connectToA(_muxProxy);
    _muxProxy.connectToB(_factoryProxy);
    _muxProxy.connectToA(_coOrdProxy);
    _coOrdProxy.connectToB(_muxProxy);
    ccCrossConnectorMux::instance()->connectToB(_factoryProxy, 
                                                _linkIdentifier);
    return;
}

void swLink :: setLinkIdentifier(pfUlong linkIdentifier_)
{
    _linkIdentifier = linkIdentifier_;

    _factoryProxy.setId(linkIdentifier_);
    _muxProxy.setId(linkIdentifier_);
    _coOrdProxy.setId(linkIdentifier_);
    return;
}
