//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project/CC
//
//File: ccodp_busy.cpp
//
//Version: $Revision: 1.6 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/11/11 14:56:17 $
//
//Organisation:
//      University of Technology
// 
//Author:
//      Pasi Nummisalo
//
//Description:
//     
//
//Copyright:
//     University of Technology
//     Laboratory of Telecommunications and Multimedia 
//      
//Licence:
//     
//
//History:

#include "ccostate_analyse.h"
#include "ccostate_selectroute.h"
#include "ccostate_collect.h"
#include "ccostate_exception.h"
#include "protocol/cc/ccprotocol.h"
#include "ccodp_busy.h"

ccOdpCalledPartyBusy *ccOdpCalledPartyBusy :: _only = 0;

ccOdpCalledPartyBusy :: ccOdpCalledPartyBusy(void)
{
    return;
}

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

ccOdpCalledPartyBusy *ccOdpCalledPartyBusy :: instance(void)
{
    if(_only == 0)
    {
        _only = new ccOdpCalledPartyBusy;
        assert(_only != 0);
    }
    return _only;
}

//
//Function: proceed
//
//Description:
//   This function is called from PIC when it is time
//   to check DP criteria. Function reads the right
//   dp object from protocol and passes it to common
//   process function in base class.
//
//

void ccOdpCalledPartyBusy :: proceed(ccProtocol *protocol_)
{
#if CC_DEBUG
traceDp(ccCC,"Called Party Busy");
#endif

    process(protocol_->getDp(getInapType()), protocol_);

    return;
}

//
//Function: toNextState
//
//Description:
//    Next state (default).  
//
//

void ccOdpCalledPartyBusy :: toNextState(ccDp &, ccProtocol *protocol_)
{
    // ++TODO++
    // Is this correct?
    exitAction(protocol_, ccOstateException::instance());
    
    return;   
   
}

//
//Functions: 
//
//Description:
//        Get DP specific information   
//


toveinap_EventTypeBCSMType ccOdpCalledPartyBusy :: getInapType(void) const
{
    return toveinap_oCalledPartyBusy;
}

string ccOdpCalledPartyBusy :: getType(void) const
{
    string result("CalledPartyBusy");
    return result;
}

ccIf_TriggersType ccOdpCalledPartyBusy :: allowedTriggers(void) const
{
    ccIf_TriggersType triggers;
    
    triggers.length(0);
    
    return triggers;
}


//
//Functions: binap-inputs
//
//Description: see base class
//
//

void ccOdpCalledPartyBusy :: binapCONTINUEpduAct(
    binapCONTINUEpdu *,
    ccProtocol *protocol_)
{
    
    // Is there more TDP-Rs?
    processTDP_R(protocol_->
                 getDpValueObject(ccDpCalledPartyBusy), protocol_);
    
    return;
}

void ccOdpCalledPartyBusy :: binapSELECT_ROUTEpduAct(
    binapSELECT_ROUTEpdu *,
    ccProtocol *protocol_)
{
    exitAction(protocol_, ccOstateSelectRoute::instance());
    
    return;
}

void ccOdpCalledPartyBusy :: binapANALYSE_INFORMATIONpduAct(
    binapANALYSE_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
    exitAction(protocol_, ccOstateAnalyseInformation::instance());

    return;    
}

void ccOdpCalledPartyBusy :: binapCOLLECT_INFORMATIONpduAct(
    binapCOLLECT_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
    exitAction(protocol_, ccOstateCollectInformation::instance());

    return;
}
