00001 /* 00002 * Copyright 1997, Brown University, Providence, RI. 00003 * 00004 * All Rights Reserved 00005 * 00006 * Permission to use, copy, modify, and distribute this software and its 00007 * documentation for any purpose other than its incorporation into a 00008 * commercial product is hereby granted without fee, provided that the 00009 * above copyright notice appear in all copies and that both that 00010 * copyright notice and this permission notice appear in supporting 00011 * documentation, and that the name of Brown University not be used in 00012 * advertising or publicity pertaining to distribution of the software 00013 * without specific, written prior permission. 00014 * 00015 * BROWN UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00016 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY 00017 * PARTICULAR PURPOSE. IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE FOR 00018 * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00019 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00020 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00021 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00022 */ 00023 #ifndef TTY_UNIX_HAS_BEEN_INCLUDED 00024 #define TTY_UNIX_HAS_BEEN_INCLUDED 00025 00026 #include "std/list.H" 00027 #include "tty/tty.H" 00028 00029 00030 class UNIX_MANAGER : public FD_MANAGER { 00031 public: 00032 class tty_to_id { 00033 public: 00034 FD_EVENT *_fd; 00035 tty_to_id() : _fd(0) { } 00036 tty_to_id(FD_EVENT *fd) : _fd(fd) { } 00037 int operator == (const tty_to_id &i) const { return _fd == i._fd; } 00038 }; 00039 00040 protected : 00041 ARRAY<tty_to_id> _ids; 00042 00043 virtual void add(FD_EVENT *fd) { _ids += tty_to_id(fd); } 00044 virtual void rem(FD_EVENT *fd) { if (_ids.contains(tty_to_id(fd))) 00045 _ids -= tty_to_id(fd); } 00046 00047 virtual void add(FD_TIMEOUT *fd) { FD_MANAGER::add(fd);} 00048 virtual void rem(FD_TIMEOUT *fd) { FD_MANAGER::rem(fd);} 00049 00050 public : 00051 UNIX_MANAGER() { } 00052 00053 virtual void loop(int infinite = 1); 00054 }; 00055 #endif