/home/vlg/develop/libASSA/libassa/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 <string>
00026 #include <sstream>
00027 #include <iostream>
00028 #include <list>
00029 
00030 #include "assa/Logger.h"
00031 
00032 namespace ASSA {
00033 
00050 class FdSet : public fd_set
00051 {
00052 public:
00055     FdSet ();
00056 
00061     bool setFd (handler_t fd_);
00062 
00067     bool clear (handler_t fd_);
00068 
00073     bool isSet (handler_t fd_);
00074 
00077     void sync ();
00078 
00081     void reset ();
00082 
00086     int numSet ();
00087 
00090     void dump  ();
00091 
00094     std::string dump_c_str ();
00095 
00096 private:
00097 
00098 #if !defined (WIN32)
00099     typedef std::list<u_int>::iterator ActiveFDs_Iter;
00100 
00101     std::list<u_int> m_actfds;  
00102 #endif
00103 };
00104 
00105 //------------------------------------------------------------------------------
00106 // Member Functions
00107 //------------------------------------------------------------------------------
00108 inline      FdSet::FdSet  () { reset (); }
00109 inline void FdSet::dump   () { DL ((REACT, "%s\n", dump_c_str ().c_str ())); }
00110 
00111 inline bool FdSet::isSet  (handler_t fd_) { return FD_ISSET (fd_, this); }
00112 
00113 inline int
00114 FdSet::
00115 numSet () 
00116 { 
00117 #if defined (WIN32)
00118     return this->fd_count; 
00119 #else  /* UNIX */
00120     return m_actfds.size ();
00121 #endif
00122 }
00123 
00124 
00125 } // end namespace ASSA
00126 
00127 #endif /* FDSET_H */  

Generated on Sun Aug 13 15:08:00 2006 for libassa by  doxygen 1.4.6