SelectorImplBSD.h

Go to the documentation of this file.
00001 /****************** <VPR heading BEGIN do not edit this line> *****************
00002  *
00003  * VR Juggler Portable Runtime
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Patrick Hartling, Kevin Meinert, Carolina Cruz-Neira
00007  *
00008  * -----------------------------------------------------------------
00009  * File:          $RCSfile$
00010  * Date modified: $Date: 2005-01-17 22:34:01 -0600 (Mon, 17 Jan 2005) $
00011  * Version:       $Revision: 16635 $
00012  * -----------------------------------------------------------------
00013  *
00014  ****************** <VPR heading END do not edit this line> ******************/
00015 
00016 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00017  *
00018  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00019  *
00020  * Original Authors:
00021  *   Allen Bierbaum, Christopher Just,
00022  *   Patrick Hartling, Kevin Meinert,
00023  *   Carolina Cruz-Neira, Albert Baker
00024  *
00025  * This library is free software; you can redistribute it and/or
00026  * modify it under the terms of the GNU Library General Public
00027  * License as published by the Free Software Foundation; either
00028  * version 2 of the License, or (at your option) any later version.
00029  *
00030  * This library is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00033  * Library General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU Library General Public
00036  * License along with this library; if not, write to the
00037  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00038  * Boston, MA 02111-1307, USA.
00039  *
00040  *************** <auto-copyright.pl END do not edit this line> ***************/
00041 
00042 #ifndef _VPR_SELECTOR_IMPL_BSD_H_
00043 #define _VPR_SELECTOR_IMPL_BSD_H_
00044 
00045 #include <vpr/vprConfig.h>
00046 
00047 #include <vector>
00048 
00049 #include <vpr/IO/SelectorBase.h>
00050 #include <vpr/IO/IOSys.h>
00051 #include <vpr/Util/ReturnStatus.h>
00052 #include <vpr/Util/Interval.h>
00053 
00054 
00055 namespace vpr
00056 {
00057 
00068 class SelectorImplBSD : public SelectorBase
00069 {
00070 public:
00071    // XXX: What should we do when we are adding a handler while
00072    //    also iterating through the current handles.  Bad things "may" happend
00073    // This happens ALL the time with acceptors because they add to the reactor
00074    // as they are executing an handleEvent themselves
00075 
00091    bool addHandle(vpr::IOSys::Handle handle, vpr::Uint16 mask = 0);
00092 
00104    bool removeHandle(vpr::IOSys::Handle handle);
00105 
00117    bool setIn(vpr::IOSys::Handle handle, vpr::Uint16 mask);
00118 
00128    vpr::Uint16 getIn(vpr::IOSys::Handle handle);
00129 
00143    vpr::Uint16 getOut(vpr::IOSys::Handle handle);
00144 
00166    vpr::ReturnStatus select(vpr::Uint16& numWithEvents,
00167                             const vpr::Interval timeout = vpr::Interval::NoTimeout);
00168 
00174    vpr::Uint16 getNumHandles()
00175    {
00176       return mPollDescs.size();
00177    }
00178 
00189    vpr::IOSys::Handle getHandle(vpr::Uint16 index)
00190    {
00191       return mPollDescs[index].fd;
00192    }
00193 
00203    bool containsHandle(vpr::IOSys::Handle handle)
00204    {
00205       return (getHandle(handle) != mPollDescs.end());
00206    }
00207 
00208 protected:
00210    struct BSDPollDesc
00211    {
00212       int         fd;
00213       vpr::Uint16 in_flags;
00214       vpr::Uint16 out_flags;
00215    };
00216 
00223    std::vector<BSDPollDesc>::iterator getHandle(int handle);
00224 
00226    std::vector<BSDPollDesc> mPollDescs;
00227 };
00228 
00229 } // End of vpr namespace
00230 
00231 
00232 #endif  /* _VPR_SELECTOR_IMPL_BSD_H_ */

Generated on Thu Jan 4 10:52:10 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1