//Editor-Info: -*- C++ -*-
//
//Subject: TOVE project / OVOPS++
//
//File: conduit.h
//
//Version: $Revision: 1.37 $
//
//State: $State: Exp $
//
//Date: $Date: 1998/10/05 07:24:27 $
//
//Organisation:
//      Helsinki University of Technology
//      Laboratory of Telecommunications Software and Multimedia
// 
//Authors:
//      Pasi Nummisalo
//      Juhana Räsänen
//	Timo Pärnänen
//	Vesa-Matti Puro
//
//Description:
//      The protocol framework is made up of two sorts of objects,
//      conduits and information chunks. A conduit is a proxy to a
//      conduit implementation which is a software component with two
//      distinct sides, sideA and sideB. A Conduit (ConduitImp) can be
//      connected on each of its sides to other conduits, which are its
//      neighbor conduits. A Conduit accepts chunks of information from
//      a neighbor conduit on one side and delivers them to a conduit
//      on the opposite side. Conduits are bidirectional, so both its
//      neighbors can send it information.
//
//      Conduit is a smart reference which is a replacement for a bare pointer
//      that performs additional actions when an object is accessed eg. counts
//      the number of references to the real object (protocols, muxes, etc.)
//      so that it can be freed automatically when there are no more 
//      references (also called smart pointer).
//
//      Proxy pattern provides a surrogate or placeholder for another
//      object to control access to it.
//
//Copyright:     
//      Copyright 1999 Helsinki University of Technology
//      ALL RIGHTS RESERVED BETWEEN JANUARY 1996 AND JUNE 1999.
//
//      
//Licence:
//     
//
//History:
//
//
 
#ifndef __PF_CONDUIT_H__
#define __PF_CONDUIT_H__

class pfTransporter;
class pfConduit;
class pfProtocol;

#include <typeinfo>
#include "types.h"
#include "exception.h"

class pfConduit
{
    public:
        explicit pfConduit(pfProtocol *implementation_ = 0);
        pfConduit(const pfConduit &other_);
        virtual ~pfConduit(void);
        
        const pfConduit& operator = (const pfConduit &other_);
        int operator == (const pfConduit &other_) const;
        int operator != (const pfConduit &other_) const;

        virtual pfConduit clone(void) const;

        virtual void setId(pfId id_);
        virtual pfId getId(void) const;
        virtual void setKey(pfKey key_);
        virtual pfKey getKey(void) const;
        
        virtual void accept(pfTransporter *transporter_)
            throw(pfNullPointerException);

        virtual void connectToA(pfConduit &conduit_);
        virtual void connectToB(pfConduit &conduit_);
        virtual void disconnect(void);

        // Methods used for trace
        virtual void setTraceOn(void);
        virtual string getName(void) const;
        virtual long getAddress(void) const;

    protected:
        virtual void incRefCount(void);
        virtual void decRefCount(void);

    private:
        pfProtocol *_implementation;
};

#endif // __PF_CONDUIT_H__

