3 // $Id: Handle_Set.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/Log_Msg.h"
7 // todo: This should be cleaned up a bit.
8 // memset for FD_ZERO on OpenBSD and Solaris w/ gcc 2.95.3
9 #include "ace/os_include/os_string.h"
11 // FreeBSD 4.8-RC? for bzero() used by FD_ZERO
12 #include "ace/os_include/os_strings.h"
14 // IRIX5 defines bzero() in this odd file... used by FD_ZERO
15 #if defined (ACE_HAS_BSTRING)
16 # include /**/ <bstring.h>
17 #endif /* ACE_HAS_BSTRING */
19 // AIX defines bzero() in this odd file... used by FD_ZERO
20 #if defined (ACE_HAS_STRINGS)
21 # include "ace/os_include/os_strings.h"
22 #endif /* ACE_HAS_STRINGS */
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 // Initialize the bitmask to all 0s and reset the associated fields.
29 ACE_Handle_Set::reset (void)
31 ACE_TRACE ("ACE_Handle_Set::reset");
34 #if defined (ACE_HAS_BIG_FD_SET)
37 #endif /* ACE_HAS_BIG_FD_SET */
39 // #if !defined (ACE_HAS_BIG_FD_SET) Why is this here? -Steve Huston
40 FD_ZERO (&this->mask_);
41 // #endif /* ACE_HAS_BIG_FD_SET */
44 #if defined (ACE_HAS_BIG_FD_SET)
45 ACE_INLINE ACE_Handle_Set &
46 ACE_Handle_Set::operator = (const ACE_Handle_Set &rhs)
48 ACE_TRACE ("ACE_Handle_Set::operator =");
66 #endif /* ACE_HAS_BIG_FD_SET */
68 // Returns the number of the large bit.
71 ACE_Handle_Set::max_set (void) const
73 ACE_TRACE ("ACE_Handle_Set::max_set");
74 return this->max_handle_;
77 // Checks whether handle is enabled.
80 ACE_Handle_Set::is_set (ACE_HANDLE handle) const
82 ACE_TRACE ("ACE_Handle_Set::is_set");
83 #if defined (ACE_HAS_BIG_FD_SET)
84 return FD_ISSET (handle,
87 #elif defined (ACE_HAS_NONCONST_FD_ISSET)
88 return FD_ISSET (handle,
89 const_cast<fd_set*> (&this->mask_));
91 return FD_ISSET (handle,
93 #endif /* ACE_HAS_BIG_FD_SET */
96 // Enables the handle.
99 ACE_Handle_Set::set_bit (ACE_HANDLE handle)
101 ACE_TRACE ("ACE_Handle_Set::set_bit");
102 if ((handle != ACE_INVALID_HANDLE)
103 && (!this->is_set (handle)))
105 #if defined (ACE_WIN32)
106 FD_SET ((SOCKET) handle,
109 #else /* ACE_WIN32 */
110 #if defined (ACE_HAS_BIG_FD_SET)
111 if (this->size_ == 0)
112 FD_ZERO (&this->mask_);
114 if (handle < this->min_handle_)
115 this->min_handle_ = handle;
116 #endif /* ACE_HAS_BIG_FD_SET */
122 if (handle > this->max_handle_)
123 this->max_handle_ = handle;
124 #endif /* ACE_WIN32 */
128 // Disables the handle.
131 ACE_Handle_Set::clr_bit (ACE_HANDLE handle)
133 ACE_TRACE ("ACE_Handle_Set::clr_bit");
135 if ((handle != ACE_INVALID_HANDLE) &&
136 (this->is_set (handle)))
138 FD_CLR ((ACE_SOCKET) handle,
142 #if !defined (ACE_WIN32)
143 if (handle == this->max_handle_)
144 this->set_max (this->max_handle_);
145 #endif /* !ACE_WIN32 */
149 // Returns a count of the number of enabled bits.
152 ACE_Handle_Set::num_set (void) const
154 ACE_TRACE ("ACE_Handle_Set::num_set");
155 #if defined (ACE_WIN32)
156 return this->mask_.fd_count;
157 #else /* !ACE_WIN32 */
159 #endif /* ACE_WIN32 */
162 // Returns a pointer to the underlying fd_set.
165 ACE_Handle_Set::operator fd_set *()
167 ACE_TRACE ("ACE_Handle_Set::operator fd_set *");
170 return (fd_set *) &this->mask_;
175 // Returns a pointer to the underlying fd_set.
178 ACE_Handle_Set::fdset (void)
180 ACE_TRACE ("ACE_Handle_Set::fdset");
183 return (fd_set *) &this->mask_;
189 ACE_Handle_Set_Iterator::~ACE_Handle_Set_Iterator (void)
193 ACE_END_VERSIONED_NAMESPACE_DECL