VR-Link API Documentation for HLA Evolved
vlSelectParamW.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 *********************************************************************/
00008 #pragma once
00009 
00010 #ifdef DtUSE_UTILITIES_NAMESPACE
00011 namespace DtUSE_UTILITIES_NAMESPACE
00012 {
00013 #endif
00014 
00015 
00016 class DtSelectParamWithWrite 
00017 {
00018    public:
00019       DtSelectParamWithWrite();
00020 
00021       int select(DtTime timeout);
00022       void addRead(int fd);
00023       void delRead(int fd);
00024       int canRead(int fd);
00025       void addWrite(int fd);
00026       void clearWrite();
00027       
00028    protected:
00029       int myMaxFD;
00030       fd_set myRead0, myRead;
00031       fd_set myWrite0, myWrite;
00032 };
00033 
00034 inline 
00035 DtSelectParamWithWrite::DtSelectParamWithWrite() 
00036 {
00037    FD_ZERO(&myRead0);
00038    FD_ZERO(&myWrite0);
00039    myRead = myRead0;
00040    myWrite = myWrite0;
00041    myMaxFD = -1; 
00042 }
00043 
00044 inline int 
00045 DtSelectParamWithWrite::select(DtTime timeout) 
00046 {
00047    myRead = myRead0;
00048    myWrite = myWrite0;
00049    return DtSelect(myMaxFD+1, &myRead, &myWrite, NULL, timeout);
00050 }
00051 
00052 inline void 
00053 DtSelectParamWithWrite::addRead(int fd) 
00054 { 
00055    FD_SET((unsigned int) fd, &myRead0); 
00056    myMaxFD = DtMax(myMaxFD, fd);
00057 }
00058 
00059 inline void 
00060 DtSelectParamWithWrite::delRead(int fd) 
00061 { 
00062    FD_CLR((unsigned int) fd, &myRead0); 
00064 }
00065 
00066 inline int 
00067 DtSelectParamWithWrite::canRead(int fd) 
00068 {      
00069    return ((int)(FD_ISSET((unsigned int) fd, &myRead)));
00070 }
00071 
00072 inline void 
00073 DtSelectParamWithWrite::addWrite(int fd) 
00074 { 
00075    FD_SET((unsigned int) fd, &myWrite0); 
00076    myMaxFD = DtMax(myMaxFD, fd);
00077 }
00078 
00079 inline void 
00080 DtSelectParamWithWrite::clearWrite() { 
00081    FD_ZERO(&myWrite0);
00082 }
00083 
00084 #ifdef DtUSE_UTILITIES_NAMESPACE
00085 } 
00086 #endif
00087 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)