//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project
//
//File: 
//
//Version: $Revision: 1.1 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/08/03 11:40:43 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//
//
//Description:
//      See corresponding header file
//
//Copyright:
//
//
//Licence:
//
//
//History: 

#include "iface/cpcsif/cpcsupprimitives.h"
#include "iface/cpcsif/cpcsdownprimitives.h"
#include "gsnprotocol.h"
#include "gsnstate.h"

gsnState *gsnState::_only = 0;

gsnState *gsnState :: instance(void)
{
    if (_only == 0)
    {
        _only = new gsnState;
    }
    return _only;
}

//
//Functions: gsnState
//
//Description:
//    constructor
//

gsnState :: gsnState(void)
{
    return;
}

//
//Functions: ~gsnState
//
//Description:
//    destructor
//

gsnState :: ~gsnState(void)
{
    _only = 0;
    return;   
}

//
//Functions: cpcsUNITDATAindAct
//
//Description:
//    switches the data from input connection to output connection
//    and sends it to the right side.
//

void gsnState :: cpcsUNITDATAindAct(cpcsUNITDATAind *messenger_,
                                    pfProtocol *protocol_) const
{
    cpcsUNITDATAreq *messenger;
    gsnProtocol *protocol = dynamic_cast<gsnProtocol*>(protocol_);

    messenger = protocol->switchData(messenger_);

    if ((messenger_->isFromA()) != 0)
    {
        protocol->toB(messenger);
    }
    else
    {
        protocol->toA(messenger);
    }
    
    return;
}



