/builddir/build/BUILD/libassa-3.5.0/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 
00084 
00088     int maxInSet ();
00089 
00093     int numSet ();
00094 
00101     void dump  ();
00102 
00105     std::string dump_c_str ();
00106 
00107 private:
00108 
00109 #if !defined (WIN32)
00110     typedef std::list<u_int>::iterator ActiveFDs_Iter;
00111 
00112     std::list<u_int> m_actfds;  
00113 #endif
00114 };
00115 
00116 //------------------------------------------------------------------------------
00117 // Member Functions
00118 //------------------------------------------------------------------------------
00119 inline      FdSet::FdSet  () { reset (); }
00120 inline void FdSet::dump   () { DL ((REACT, "%s\n", dump_c_str ().c_str ())); }
00121 
00122 inline bool FdSet::isSet  (handler_t fd_) { return FD_ISSET (fd_, this); }
00123 
00124 inline int
00125 FdSet::
00126 numSet () 
00127 { 
00128 #if defined (WIN32)
00129     return this->fd_count; 
00130 #else  /* UNIX */
00131     return m_actfds.size ();
00132 #endif
00133 }
00134 
00135 
00136 } // end namespace ASSA
00137 
00138 #endif /* FDSET_H */  

Generated on Sun Feb 10 14:51:33 2008 for libassa by  doxygen 1.5.4