From cd2355d463b194d1b7ed86487239d16e4a0babfa Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 28 Nov 2000 17:07:44 +0000 Subject: * Removed virtual UchChannel::Copy () * Removed virutal UchChannel::HandleSelect () * Smart(ies) removed by Stephane Sire * Removed ReadHandler and WriteHandler * NFILE -> 64, en attendant mieux --- comm/Channel.h | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'comm/Channel.h') diff --git a/comm/Channel.h b/comm/Channel.h index 4a6d5f9..32271cf 100644 --- a/comm/Channel.h +++ b/comm/Channel.h @@ -3,7 +3,7 @@ * * by Michel Beaudouin-Lafon * - * Copyright 1990-1995 + * Copyright 1990-1997 * Laboratoire de Recherche en Informatique (LRI) * * File descriptors, channels @@ -20,18 +20,17 @@ #endif #include "cplus_bugs.h" -#include "global.h" +#include "ccu/bool.h" #include "IOS.h" -#include "ccu/SmartPointer.h" - -// we need read and write system calls -#include class UchMsgBuffer; class CcuString; +// we need read and write system calls +#include + #ifndef NFILE -#define NFILE 20 +#define NFILE 64 #endif enum IOMODE { IONone = 0, IORead = 1, IOWrite = 2, @@ -50,7 +49,7 @@ protected: public: inline UchFilDes () : Fd (-1) { } inline UchFilDes (const UchFilDes& fd) { Use (Fd = fd.Fd); } -inline UchFilDes (int fd) { Use (Fd = fd); } +inline UchFilDes (int fd) { Use (Fd = fd); } inline ~UchFilDes () { Unuse (Fd); } inline operator int () const { return Fd; } @@ -67,22 +66,19 @@ inline int Write (byte* b, int n) { return write (Fd, (const char*) b, n); } // This class defines channels, ie file descriptors with handlers for read/write. // The file descriptor of a channel is immutable: once created, it cannot change; // this is crucial for channel sets, for instance. -// However, because Copy and operator= are defined,immutability can be -// potentially bypassed... -// UchChannel also derives from CcuSmartData, for building smart pointers +// Be careful with Copy and operator= if redefined because this can +// potentially bypass immutability. // -class UchChannel; -typedef void (* CH_HANDLER) (UchChannel *); -class UchChannel : public CcuSmartData, public UchIOS { +class UchChannel : public UchIOS { friend class UchBaseMultiplexer; protected: UchFilDes Fd; IOMODE Mode; UchBaseMultiplexer* Mpx; -virtual void Added (UchBaseMultiplexer&); -virtual void Removed (UchBaseMultiplexer&); +virtual void Added (); +virtual void Removed (); public: UchChannel (); @@ -90,17 +86,19 @@ public: UchChannel (const UchChannel& ch); ~UchChannel (); + inline void Open (int fd) { if (Fd < 0) Fd.Open (fd); } +inline void Close () { if (Fd.Opened ()) Fd.Close (); } inline IOMODE IOMode () const { return Mode; } inline void SetMode (IOMODE io) { Mode = io; } int Read (UchMsgBuffer&); int Write (UchMsgBuffer&); bool ReadBuffer (UchMsgBuffer&); bool WriteBuffer (UchMsgBuffer&); -virtual UchChannel* Copy () const; + void Add (UchBaseMultiplexer*); + void Remove (); virtual void HandleWrite (); virtual void HandleRead (); -virtual bool HandleSelect (); inline int FilDes () const { return Fd; } inline int Read (byte* b, int n) { return read (Fd, (char*) b, n); } @@ -124,12 +122,7 @@ virtual bool ReadChar (char&); virtual int ReadString (char*, int); virtual int ReadString (CcuString&); virtual bool ReadBuf (byte*, int); - -static CH_HANDLER ReadHandler; -static CH_HANDLER WriteHandler; }; -PointerClass (pUchChannel, UchChannel) - #endif /* Channel_H_ */ -- cgit v1.1