//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / CPCS module
//
//File: cpcsuadapter.h
//
//Version: $Revision: 1.7 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/12/16 13:55:11 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
//
//Author:
//      Juhana Räsänen
//
//Description:
//      CPCS level interface class from Conduit+ world to outside world.
//
//Copyright:
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//Licence:
//
//
//History: 
//

#ifndef __CPCS_CPCSUADAPTER_H__
#define __CPCS_CPCSUADAPTER_H__

#include "cpcs.h"
#include "pf/udpsocket.h"

//
//Class: cpcsUDPAdapter
//
//Description:
//    This class is an interface from the Conduit+ world to a UDP socket.
//    CPCS adapter accepts CPCS SDUs (in cpcsUNITDATAreq messengers),
//    takes the data and sends it as a write request to the device
//    being the adapter.
//    Adapter also provides a callback function for the device so that
//    it can give all messages received from the socket to the adapter,
//    which makes a cpcsUNITDATAind messenger of the data and sends it
//    to the Conduit connencted to the adapter A side.
//

class cpcsUDPAdapter : public pfUDPsocket
{
    public:
        static pfConduit createUDPConnection(
            string hostname_,
            int localPort_,
            int remotePort_,
            pfUlong sduSize_ = CPCS_MAX_SDU_SIZE);
        
        // ++TODO++ change constructor to protected when saal connection
        //          is deprecated.
        cpcsUDPAdapter(pfUlong sduSize_);

        virtual ~cpcsUDPAdapter(void);

        void readAction(pfFrame &frame_, pfUlong code_);
        void writeAction(pfUlong code_);

    protected:
        // Protect the clone method, because it
        // is not applicable as the CPCS adapter represents a physical
        // resource that cannot be cloned (ATM VC or UDP connection).
        virtual pfProtocol *cloneImplementation(void) const;

#ifdef DEBUG
    public:
        void setDebug(void);
        void clearDebug(void);
        bool debugActive(void) const;

    private:
        cpcsUDPAdapter(const cpcsUDPAdapter &other_);
        bool _debug;
#endif // DEBUG

};

#endif  // __CPCS_CPCSUADAPTER_H__

