//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project/CC
//
//File: ccodp_collectedinfo.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_collectedinfo.h"

ccOdpCollectedInformation *ccOdpCollectedInformation :: _only = 0;

ccOdpCollectedInformation :: ccOdpCollectedInformation(void)
{
    return;
}

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

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

    return;
}

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

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

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


toveinap_EventTypeBCSMType ccOdpCollectedInformation :: getInapType(void) const
{
    return toveinap_collectedInfo;
}

string ccOdpCollectedInformation :: getType(void) const
{
    string result("collectedInfo");
    return result;
}

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

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

    return triggers;
}


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

void ccOdpCollectedInformation :: binapCONTINUEpduAct(
    binapCONTINUEpdu *,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"CollectedInfo","CONTINUEpdu");
#endif    
    
    // Is there more TDP-Rs?
    processTDP_R(protocol_->
                 getDpValueObject(ccDpCollectedInformation), protocol_);

    return;
}

void ccOdpCollectedInformation :: binapCOLLECT_INFORMATIONpduAct(
    binapCOLLECT_INFORMATIONpdu *,
    ccProtocol *protocol_)
{
    exitAction(protocol_, ccOstateCollectInformation::instance());
 
    return;
}

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

void ccOdpCollectedInformation :: binapSELECT_ROUTEpduAct(
    binapSELECT_ROUTEpdu *,
    ccProtocol *protocol_)
{
#if CC_DEBUG
traceInput(ccINGW,ccCC,"-CollectedInfo-","SELECT_ROUTEpdu");
#endif     
    exitAction(protocol_, ccOstateSelectRoute::instance());
    
    return;
}








