//Editor-Info: -*- C++ -*-
//
//Subject: TOVE-project / MTP3 protocol
//
//File: mtp3state_hmdc_idle.cpp
//
//Version: $Revision: 1.8 $
//
//Date: $Date: 1998/04/20 08:36:01 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications and Multimedia
//
//Author:
//      Petteri Koponen
//      Timo Pärnänen
//
//Description:
//      See corresponding header file.
//
//Copyright:
//
//
//Licence:
//
//
//History:

#include "pf/frame.h"
#include "mtp3block_hmdc.h"
#include "mtp3state_hmdc_idle.h"

// implementations of constructors, destructor and singleton pattern

mtp3_HMDC_Idle *mtp3_HMDC_Idle::_only = 0;

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

mtp3_HMDC_Idle :: mtp3_HMDC_Idle(void)
{
    return;
}

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

void mtp3_HMDC_Idle :: naalRECEIVED_MESSAGEindAct(
    naalRECEIVED_MESSAGEind *messenger_,
    pfProtocol *protocol_)
{
    // destined to this SP? Checks the destination point code from the frame
    pfFrame messageUnit = messenger_->getMessageUnit();
    mtp3BlockHMDC *block = (mtp3BlockHMDC *)protocol_;

    if (block->destinatedToThisSP(messageUnit) == 1)
    {
        // distribute the message
        block->toHMDT(messenger_);
    }
    else
    {
        // ++TODO++
        // Check here, is own SP restart (when this feature is implemented)

        // route the msg forward
        block->toHMRT(messenger_);
    }
    return;
}
