Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

iodev.cc

Go to the documentation of this file.
00001 // 
00002 // iodev.cc      : Diffusion IO Devices
00003 // authors       : Fabio Silva
00004 //
00005 // Copyright (C) 2000-2002 by the University of Southern California
00006 // $Id: iodev.cc,v 1.6 2002/11/26 22:45:39 haldar Exp $
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License,
00010 // version 2, as published by the Free Software Foundation.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License along
00018 // with this program; if not, write to the Free Software Foundation, Inc.,
00019 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00020 //
00021 //
00022 
00023 #include "iodev.hh"
00024 
00025 DiffusionIO::DiffusionIO()
00026 {
00027   num_out_descriptors_ = 0;
00028   num_in_descriptors_ = 0;
00029   max_in_descriptor_ = 0;
00030 }
00031 
00032 void DiffusionIO::addInFDS(fd_set *fds, int *max)
00033 {
00034   list<int>::iterator itr;
00035 
00036   for (itr = in_fds_.begin(); itr != in_fds_.end(); ++itr){
00037     FD_SET(*itr, fds);
00038   }
00039 
00040   if (max_in_descriptor_ > *max)
00041     *max = max_in_descriptor_;
00042 }
00043 
00044 int DiffusionIO::checkInFDS(fd_set *fds)
00045 {
00046   list<int>::iterator itr;
00047   int fd;
00048 
00049   for (itr = in_fds_.begin(); itr != in_fds_.end(); ++itr){
00050     fd = *itr;
00051     if (FD_ISSET(fd, fds)){
00052       return (fd);
00053     }
00054   }
00055   return 0;
00056 }
00057 
00058 bool DiffusionIO::hasFD(int fd)
00059 {
00060   list<int>::iterator itr;
00061   int device_fd;
00062 
00063   for (itr = in_fds_.begin(); itr != in_fds_.end(); ++itr){
00064     device_fd = *itr;
00065     if (device_fd == fd)
00066       return true;
00067   }
00068   return false;
00069 }

Generated on Tue Apr 20 12:14:20 2004 for NS2.26SourcesOriginal by doxygen 1.3.3