//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / SW
//
//File: swnnilink.cpp
//
//Version: $Revision: 1.8 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/11/19 12:31:43 $
//
//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 <autoptr.h>
#include "pf/factory.h"
#include "pf/mux.h"
#include "pf/debug.h"
#include "protocol/bisup/bisupstrings.h"
#include "protocol/bisup/niprotocol.h"
#include "swswitch.h"
#include "swnnilink.h"

// create & clone

swNNIlink *swNNIlink :: createPrototype(void)
{
    swNNIlink *newLink = new swNNIlink();
    return newLink;
}

swNNIlink *swNNIlink :: clonePrototype(pfUlong linkIdentifier_,
                                       pfUlong destinationPointCode_)
{
    auto_ptr<swNNIlink> newLink(new swNNIlink(*this));
    newLink->setConduits(linkIdentifier_, destinationPointCode_);
    newLink->connectProtocols();
    return newLink.release();
}

// constructors & destructor

swNNIlink :: swNNIlink(void)
    : swLink()
{
    return;
}

swNNIlink :: swNNIlink(const swNNIlink &other_)
    : swLink(other_)
{
    return;
}

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

void swNNIlink :: setConduits(pfId linkIdentifier_,
                              pfUlong destinationPointCode_)
{
    // REMOVE
    string bisupMuxReferenceStr("Mux reference");   

    pfConduit bisupProxy = swSwitch::instance()->getNNIprototype();
    bisupProxy.setId(linkIdentifier_);
    _factoryProxy = pfFactory::createFactory(bisupProxy);
    _muxProxy = pfMux::createMux(_maxMuxKeyValue, 
                                 bisupMuxReferenceStr);
    pfUlong pointCode = swSwitch::instance()->getPointCode();
    _coOrdProxy = niProtocol::create(pointCode,
                                     destinationPointCode_);

    setLinkIdentifier(linkIdentifier_);
    return;
}
