//Editor-Info: -*- C++ -*-
//
//Subject: TOCE project/CC
//
//File: ccodp_attemptautohorized.cpp
//
//Version: $Revision: 1.7 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/11/24 12:57:33 $
//
//Organisation:
//      University of Technology
// 
//Author:
//      Pasi Nummisalo
//
//Description:
//     
//
//Copyright:
//     University of Technology
//     Laboratory of Telecommunications and Multimedia 
//      
//Licence:
//     
//
//History:
//

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

ccOdpAttemptAuthorized *ccOdpAttemptAuthorized :: _only = 0;

ccOdpAttemptAuthorized :: ccOdpAttemptAuthorized(void)
{
    return;
}

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

ccOdpAttemptAuthorized *ccOdpAttemptAuthorized :: instance(void)
{
    if(_only == 0)
    {
        _only = new ccOdpAttemptAuthorized;
        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 ccOdpAttemptAuthorized :: proceed(ccProtocol *protocol_)
{
#if CC_DEBUG
traceDp(ccCC,"Origination Attempt Authorized");
#endif
    
    process(protocol_->getDp(getInapType()), protocol_);

    return;
}

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

void ccOdpAttemptAuthorized :: toNextState(ccDp &, ccProtocol *protocol_)
{
    exitAction(protocol_, ccOstateCollectInformation::instance());
        
    return;
}

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


toveinap_EventTypeBCSMType ccOdpAttemptAuthorized :: getInapType(void) const
{
    return toveinap_origAttemptAuthorized;
}

string ccOdpAttemptAuthorized :: getType(void) const
{
    string result("origAttemptAuthorized");
    return result;
}

ccIf_TriggersType ccOdpAttemptAuthorized :: allowedTriggers(void) const
{
    ccIf_TriggersType triggers;
    
    triggers.length(0);

    /*
    ccIf_TriggerType trigger;
    
    ccTriggerDigitString::getInfo(trigger); 
    triggers[0] = trigger;
    */

    return triggers;
}


//
//Function: fillMessengerEDP-N
//
//Description:
//   Fill specific fields to this DP   
//
//

void ccOdpAttemptAuthorized ::fillMessengerEDP_N(
                                 ccDp &,
                                 ccProtocol *)
{
    
}

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

void ccOdpAttemptAuthorized :: binapCONTINUEpduAct(
    binapCONTINUEpdu *,
    ccProtocol *protocol_)
{
    
    // Is there more TDP-Rs?
    processTDP_R(protocol_->
                 getDpValueObject(ccDpOriginationAttemptAuthorized),
                 protocol_);

    return;
}

void ccOdpAttemptAuthorized :: binapCOLLECT_INFORMATIONpduAct(
    binapCOLLECT_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
    // Continue with new data ++TODO++

    exitAction(protocol_, ccOstateCollectInformation::instance());
  
    return;   
}

void ccOdpAttemptAuthorized :: binapANALYSE_INFORMATIONpduAct(
    binapANALYSE_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
    exitAction(protocol_, ccOstateAnalyseInformation::instance());
   
    return;    
}

void ccOdpAttemptAuthorized :: binapSELECT_ROUTEpduAct(
    binapSELECT_ROUTEpdu *,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"-AttemptAuthorized-","SELECT_ROUTE");
#endif

    exitAction(protocol_, ccOstateSelectRoute::instance());
    
    return;
}






