Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Handle_Set.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: Handle_Set.i,v 1.1.1.3 2003/02/21 18:36:32 chad Exp $
00003 
00004 // Handle_Set.i
00005 
00006 // Initialize the bitmask to all 0s and reset the associated fields.
00007 
00008 ACE_INLINE void
00009 ACE_Handle_Set::reset (void)
00010 {
00011   ACE_TRACE ("ACE_Handle_Set::reset");
00012   this->max_handle_ =
00013     ACE_INVALID_HANDLE;
00014 #if defined (ACE_HAS_BIG_FD_SET)
00015   this->min_handle_ =
00016     NUM_WORDS * WORDSIZE;
00017 #endif /* ACE_HAS_BIG_FD_SET */
00018   this->size_ = 0;
00019   // #if !defined (ACE_HAS_BIG_FD_SET)      Why is this here?  -Steve Huston
00020   FD_ZERO (&this->mask_);
00021   // #endif /* ACE_HAS_BIG_FD_SET */
00022 }
00023 
00024 #if defined (ACE_HAS_BIG_FD_SET)
00025 ACE_INLINE ACE_Handle_Set &
00026 ACE_Handle_Set::operator = (const ACE_Handle_Set &rhs)
00027 {
00028   ACE_TRACE ("ACE_Handle_Set::operator =");
00029 
00030   if (rhs.size_ > 0)
00031     {
00032       this->size_ =
00033         rhs.size_;
00034       this->max_handle_ =
00035         rhs.max_handle_;
00036       this->min_handle_ =
00037         rhs.min_handle_;
00038       this->mask_ =
00039         rhs.mask_;
00040     }
00041   else
00042     this->reset ();
00043 
00044   return *this;
00045 }
00046 #endif /* ACE_HAS_BIG_FD_SET */
00047 
00048 // Returns the number of the large bit.
00049 
00050 ACE_INLINE ACE_HANDLE
00051 ACE_Handle_Set::max_set (void) const
00052 {
00053   ACE_TRACE ("ACE_Handle_Set::max_set");
00054   return this->max_handle_;
00055 }
00056 
00057 // Checks whether handle is enabled.
00058 
00059 ACE_INLINE int
00060 ACE_Handle_Set::is_set (ACE_HANDLE handle) const
00061 {
00062   ACE_TRACE ("ACE_Handle_Set::is_set");
00063 #if defined (ACE_HAS_BIG_FD_SET)
00064   return FD_ISSET (handle,
00065                    &this->mask_)
00066     && this->size_ > 0;
00067 #else
00068   return FD_ISSET (handle,
00069                    &this->mask_);
00070 #endif /* ACE_HAS_BIG_FD_SET */
00071 }
00072 
00073 // Enables the handle.
00074 
00075 ACE_INLINE void
00076 ACE_Handle_Set::set_bit (ACE_HANDLE handle)
00077 {
00078   ACE_TRACE ("ACE_Handle_Set::set_bit");
00079   if ((handle != ACE_INVALID_HANDLE)
00080       && (!this->is_set (handle)))
00081     {
00082 #if defined (ACE_WIN32)
00083       FD_SET ((SOCKET) handle,
00084               &this->mask_);
00085       this->size_++;
00086 #else /* ACE_WIN32 */
00087 #if defined (ACE_HAS_BIG_FD_SET)
00088       if (this->size_ == 0)
00089         FD_ZERO (&this->mask_);
00090 
00091       if (handle < this->min_handle_)
00092         this->min_handle_ = handle;
00093 #endif /* ACE_HAS_BIG_FD_SET */
00094 
00095       FD_SET (handle,
00096               &this->mask_);
00097       this->size_++;
00098 
00099       if (handle > this->max_handle_)
00100         this->max_handle_ = handle;
00101 #endif /* ACE_WIN32 */
00102     }
00103 }
00104 
00105 // Disables the handle.
00106 
00107 ACE_INLINE void
00108 ACE_Handle_Set::clr_bit (ACE_HANDLE handle)
00109 {
00110   ACE_TRACE ("ACE_Handle_Set::clr_bit");
00111 
00112   if ((handle != ACE_INVALID_HANDLE) &&
00113       (this->is_set (handle)))
00114     {
00115       FD_CLR ((ACE_SOCKET) handle,
00116               &this->mask_);
00117       this->size_--;
00118 
00119 #if !defined (ACE_WIN32)
00120       if (handle == this->max_handle_)
00121         this->set_max (this->max_handle_);
00122 #endif /* !ACE_WIN32 */
00123     }
00124 }
00125 
00126 // Returns a count of the number of enabled bits.
00127 
00128 ACE_INLINE int
00129 ACE_Handle_Set::num_set (void) const
00130 {
00131   ACE_TRACE ("ACE_Handle_Set::num_set");
00132 #if defined (ACE_WIN32)
00133   return this->mask_.fd_count;
00134 #else /* !ACE_WIN32 */
00135   return this->size_;
00136 #endif /* ACE_WIN32 */
00137 }
00138 
00139 // Returns a pointer to the underlying fd_set.
00140 
00141 ACE_INLINE
00142 ACE_Handle_Set::operator fd_set *()
00143 {
00144   ACE_TRACE ("ACE_Handle_Set::operator fd_set *");
00145 
00146   if (this->size_ > 0)
00147     return (fd_set *) &this->mask_;
00148   else
00149     return (fd_set *) 0;
00150 }
00151 
00152 // Returns a pointer to the underlying fd_set.
00153 
00154 ACE_INLINE fd_set *
00155 ACE_Handle_Set::fdset (void)
00156 {
00157   ACE_TRACE ("ACE_Handle_Set::fdset");
00158 
00159   if (this->size_ > 0)
00160     return (fd_set *) &this->mask_;
00161   else
00162     return (fd_set *) 0;
00163 }
00164 
00165 ACE_INLINE
00166 ACE_Handle_Set_Iterator::~ACE_Handle_Set_Iterator (void)
00167 {
00168 }

Generated on Mon Jun 16 11:19:46 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002