//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project/CC
//
//File: ccodp_analysedinfo.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_analyse.h"
#include "ccostate_selectroute.h"
#include "ccostate_collect.h"
#include "ccprotocol.h"
#include "trigger_digitstring.h"
#include "trigger_freephone.h"
#include "ccodp_analysedinfo.h"


ccOdpAnalysedInformation *ccOdpAnalysedInformation :: _only = 0;

ccOdpAnalysedInformation :: ccOdpAnalysedInformation(void)
{
    return;
}

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

//
//Function: instance
//
//Description:
//   Get pointer to this object. If this call is made first
//   time create object.(Part of sigleton pattern)
//
//

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

    return;
}

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

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

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


toveinap_EventTypeBCSMType ccOdpAnalysedInformation :: getInapType(void) const
{
    return toveinap_analysedInformation;
}

string ccOdpAnalysedInformation :: getType(void) const
{
    string result("analysedInformation");
    return result;
}

ccIf_TriggersType ccOdpAnalysedInformation :: allowedTriggers(void) const
{
    ccIf_TriggersType triggers;
    
    triggers.length(2);

    ccIf_TriggerType trigger;
    
    ccTriggerDigitString::getInfo(trigger); 
    triggers[0] = trigger;
    ccTriggerFreePhone::getInfo(trigger); 
    triggers[1] = trigger;
    
    return triggers;
}

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

void ccOdpAnalysedInformation :: binapCONTINUEpduAct(
    binapCONTINUEpdu *,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"-Analysed Information-","CONTINUE");
#endif    
    // Is there more TDP-Rs?
    processTDP_R(protocol_->getDp(getInapType()), protocol_);
    
    return;
}

void ccOdpAnalysedInformation :: binapSELECT_ROUTEpduAct(
    binapSELECT_ROUTEpdu *selectRoutePdu_,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"-Analysed Information-","SELECT_ROUTE");
#endif

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

void ccOdpAnalysedInformation :: binapANALYSE_INFORMATIONpduAct(
    binapANALYSE_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"-Analysed Information-","ANALYSE_INFORMATION");
#endif

    exitAction(protocol_, ccOstateAnalyseInformation::instance());

    return;    
}

void ccOdpAnalysedInformation :: binapCOLLECT_INFORMATIONpduAct(
    binapCOLLECT_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"-Analysed Information-","COLLECT_INFORMATION");
#endif

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

    return;
}

