/build/buildd/libassa-3.4.2/assa/FdSet.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 //                               FdSet.h
00004 //------------------------------------------------------------------------------
00005 //  Copyright (C) 1997-2002  Vladislav Grinchenko 
00006 //
00007 //  This library is free software; you can redistribute it and/or
00008 //  modify it under the terms of the GNU Library General Public
00009 //  License as published by the Free Software Foundation; either
00010 //  version 2 of the License, or (at your option) any later version.
00011 //------------------------------------------------------------------------------
00012 #ifndef FDSET_H
00013 #define FDSET_H
00014 
00017 #include <string.h>
00018 #include <sys/time.h>           /* select(3) */
00019 
00020 #if defined(Linux)              /* select(3) */
00021 #    include <sys/types.h>
00022 #    include <unistd.h>
00023 #endif
00024 
00025 #include <algorithm>
00026 #include <string>
00027 #include <sstream>
00028 #include <iostream>
00029 #include <list>
00030 
00031 #include "assa/Logger.h"
00032 
00033 namespace ASSA {
00034 
00051 class FdSet : public fd_set
00052 {
00053 public:
00056     FdSet ();
00057 
00062     bool setFd (handler_t fd_);
00063 
00068     bool clear (handler_t fd_);
00069 
00074     bool isSet (handler_t fd_);
00075 
00078     void sync ();
00079 
00082     void reset ();
00083 
00087     int numSet ();
00088 
00091     void dump  ();
00092 
00095     std::string dump_c_str ();
00096 
00097 private:
00098 
00099 #if !defined (WIN32)
00100     typedef std::list<u_int>::iterator ActiveFDs_Iter;
00101 
00102     std::list<u_int> m_actfds;  
00103 #endif
00104 };
00105 
00106 //------------------------------------------------------------------------------
00107 // Member Functions
00108 //------------------------------------------------------------------------------
00109 inline      FdSet::FdSet  () { reset (); }
00110 inline void FdSet::dump   () { DL ((REACT, "%s\n", dump_c_str ().c_str ())); }
00111 
00112 inline bool FdSet::isSet  (handler_t fd_) { return FD_ISSET (fd_, this); }
00113 
00114 inline int
00115 FdSet::
00116 numSet () 
00117 { 
00118 #if defined (WIN32)
00119     return this->fd_count; 
00120 #else  /* UNIX */
00121     return m_actfds.size ();
00122 #endif
00123 }
00124 
00125 
00126 } // end namespace ASSA
00127 
00128 #endif /* FDSET_H */  

Generated on Mon Nov 5 08:02:10 2007 for libassa by  doxygen 1.5.3-20071008