//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project
//
//File: testing/testadapter/uni/unicodingprotocol.cpp
//
//Version: $Revision: 1.5 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/03 15:17:59 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Jussi Turunen
//
//Description:
//      See corresponding header file.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 

#include <typeinfo>
#include <string>

#include "unicoderstrings.h"
#include "unicodingstate.h"
#include "unicodingprotocol.h"

uniCodingProtocol :: uniCodingProtocol()
    : pfProtocol()
{
    // pduNameList initialized here
    initializePDUnameList();    
    changeToIdleState();
    return;
}

uniCodingProtocol :: ~uniCodingProtocol(void)
{
    return;
}

pfConduit uniCodingProtocol :: create(void)
{
    uniCodingProtocol *protocol = new uniCodingProtocol();
    pfConduit conduit(protocol);
    return conduit;
}

void uniCodingProtocol :: changeToIdleState(void)
{
    changeState(uniCodingState::instance());
    return;
}

pfUlong uniCodingProtocol :: isValidPDUname(string identifier_)
{
    pfUlong isValid=0;
    pduNameListIterator name;
    for( name = _pduNames.begin(); name != _pduNames.end(); name++)
    {
        if ((*name).compare(identifier_) == 0)
        {
            isValid = 1;
            break;
        }
    }
    return isValid;
}

void uniCodingProtocol :: initializePDUnameList(void)
{
    // All the PDU names here including the _REP and _UN.
    _pduNames.push_front(ALERTStr);
    _pduNames.push_front(CALL_PROCStr);
    _pduNames.push_front(SETUPStr);
    _pduNames.push_front(CONNStr);
    _pduNames.push_front(CONN_ACKStr);
    _pduNames.push_front(RESTStr);
    _pduNames.push_front(REST_ACKStr);
    _pduNames.push_front(RELStr);
    _pduNames.push_front(REL_COMStr);
    _pduNames.push_front(STATStr);
    _pduNames.push_front(STAT_ENQStr);
    // Invalid PDUs
    _pduNames.push_front(CALL_PROC_REPStr);
    _pduNames.push_front(CALL_PROC_UNStr);
    _pduNames.push_front(SETUP_REPStr);
    _pduNames.push_front(SETUP_UNStr);
    _pduNames.push_front(CONN_REPStr);
    _pduNames.push_front(CONN_UNStr);
    _pduNames.push_front(CONN_ACK_UNStr);
    _pduNames.push_front(REST_REPStr);
    _pduNames.push_front(REL_UNStr);
    _pduNames.push_front(REL_REPStr);
    _pduNames.push_front(REL_COM_REPStr);
    _pduNames.push_front(REL_COM_UNStr);
    _pduNames.push_front(STAT_REPStr);
    _pduNames.push_front(STAT_UNStr);
    _pduNames.push_front(STAT_ENQ_UNStr);
    _pduNames.push_front(UNRECStr);

    return;
}
