vpr::Selector_t< RealSelectorImp > Class Template Reference

Cross-platform selection interface. More...

#include <vpr/IO/Selector_t.h>

Inheritance diagram for vpr::Selector_t< RealSelectorImp >:

Inheritance graph
[legend]
Collaboration diagram for vpr::Selector_t< RealSelectorImp >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool addHandle (vpr::IOSys::Handle handle, vpr::Uint16 mask=0)
 Adds the given handle to the selector.
bool removeHandle (vpr::IOSys::Handle handle)
 Removes the named handle from the selector.
bool setIn (vpr::IOSys::Handle handle, vpr::Uint16 mask)
 Sets the event flags going in to the select to mask.
vpr::Uint16 getIn (vpr::IOSys::Handle handle)
 Gets the current in flag mask.
vpr::Uint16 getOut (vpr::IOSys::Handle handle)
 Gets the current "out flag" mask after a call to select().
vpr::ReturnStatus select (vpr::Uint16 &numWithEvents, const vpr::Interval &timeout=vpr::Interval::NoTimeout)
 Poll for any ready events among the registered handles using their in flags.
vpr::Uint16 getNumHandles ()
 For iteration over the registered handles.
vpr::IOSys::Handle getHandle (vpr::Uint16 index)
 Gets the handle at the given index within the collection of registered handles.
bool containsHandle (vpr::IOSys::Handle handle)
 Test if the selector contain the given handle.

Protected Attributes

RealSelectorImp mSelectorImp
 Platform-specific implementation.

Detailed Description

template<class RealSelectorImp>
class vpr::Selector_t< RealSelectorImp >

Cross-platform selection interface.

A selector is used to wait on a set of Handles untils any of the events occur that the user is interested in. Given a platform-specific wrapper class, this is typedef'd to vpr::Selector.

Parameters:
RealSelectorImp The type that serves as the true wrapper around the platform-specific selector implementation.
See also:
vpr::SelectorNSPR, vpr::SelectorBSD

Definition at line 71 of file Selector_t.h.


Member Function Documentation

template<class RealSelectorImp>
bool vpr::Selector_t< RealSelectorImp >::addHandle ( vpr::IOSys::Handle  handle,
vpr::Uint16  mask = 0 
) [inline]

Adds the given handle to the selector.

Precondition:
handle is a valid handle.
Postcondition:
handle is added to the handle set, and initialized to a mask of no-events.
Parameters:
handle The handle to be added to this selector.
mask A bitmask specifying the events of interest for this handle. This is optional and defaults to 0 (none).
Returns:
true is returned if handle is added successfully; false otherwise.

Definition at line 88 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

Referenced by vpr::SocketConnector::complete(), vpr::BlockIO::isReadBlocked(), and vpr::BlockIO::isWriteBlocked().

00089    {
00090       return mSelectorImp.addHandle(handle, mask);
00091    }

template<class RealSelectorImp>
bool vpr::Selector_t< RealSelectorImp >::removeHandle ( vpr::IOSys::Handle  handle  )  [inline]

Removes the named handle from the selector.

Precondition:
handle is in the selector.
Postcondition:
handle is removed from the set of valid handles.
Parameters:
handle The handle to be removed from the selector's handle list.
Returns:
true is returned if handle is removed successfully; false otherwise.

Definition at line 104 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

00105    {
00106       return mSelectorImp.removeHandle(handle);
00107    }

template<class RealSelectorImp>
bool vpr::Selector_t< RealSelectorImp >::setIn ( vpr::IOSys::Handle  handle,
vpr::Uint16  mask 
) [inline]

Sets the event flags going in to the select to mask.

The flags specify which events should be selected for the given handle.

Precondition:
handle has already been added to the selector using addHandlei().
Parameters:
handle The handle whose event flags will be updated.
mask The mask used when checking for ready events on the given handle.
Returns:
true is returned if handle's event flags are set successfully; false otherwise.

Definition at line 122 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

Referenced by vpr::SocketConnector::complete(), vpr::BlockIO::isReadBlocked(), and vpr::BlockIO::isWriteBlocked().

00123    {
00124       return mSelectorImp.setIn(handle, mask);
00125    }

template<class RealSelectorImp>
vpr::Uint16 vpr::Selector_t< RealSelectorImp >::getIn ( vpr::IOSys::Handle  handle  )  [inline]

Gets the current in flag mask.

Precondition:
handle has already been added to the selector using addHandle().
Parameters:
handle The handle whose "in" event flags will be returned.
Returns:
A bitmask value representing the "in flags" of handle.

Definition at line 136 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

00137    {
00138       return mSelectorImp.getIn(handle);
00139    }

template<class RealSelectorImp>
vpr::Uint16 vpr::Selector_t< RealSelectorImp >::getOut ( vpr::IOSys::Handle  handle  )  [inline]

Gets the current "out flag" mask after a call to select().

The value returned will be the bitwise OR of the "out flags". These state which of the operations named "in flags" were found to be ready.

Precondition:
select() has been called.
Parameters:
handle The handle whose "out" event flags will be returned.
Returns:
A bitmask value representing the "out flags" of handle. These flags state which requested events were detected for handle.

Definition at line 154 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

Referenced by vpr::SocketConnector::complete().

00155    {
00156       return mSelectorImp.getOut(handle);
00157    }

template<class RealSelectorImp>
vpr::ReturnStatus vpr::Selector_t< RealSelectorImp >::select ( vpr::Uint16 numWithEvents,
const vpr::Interval timeout = vpr::Interval::NoTimeout 
) [inline]

Poll for any ready events among the registered handles using their in flags.

Parameters:
numWithEvents Upon completion, this holds the number of items that have events.
timeout The interval to wait for an event to be raised. This argument is optional and defaults to vpr::Interval::NoTimeout (wait until an event is detected withotu timing out). Passing vpr::Interval::NoWait effects a poll on the registered handles and returns immediately.
Returns:
vpr::ReturnStatus::Succeed is returned if at least one event was detected within the timeout interval.

vpr::ReturnStatus::Timeout is returned if no events were detected before the timeout expired or if vpr::Interval::NoWait was passed. In this case, numWithEvents should be checked for a value greater than 0.

vpr::ReturnStatus::Fail is returned if the select failed.

Note:
Socket should always be readable if it is not connected.

Definition at line 182 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

Referenced by vpr::SocketConnector::complete(), vpr::BlockIO::isReadBlocked(), and vpr::BlockIO::isWriteBlocked().

00184    {
00185       return mSelectorImp.select(numWithEvents, timeout);
00186    }

template<class RealSelectorImp>
vpr::Uint16 vpr::Selector_t< RealSelectorImp >::getNumHandles (  )  [inline]

For iteration over the registered handles.

Returns:
An unsigned value stating how many handles have been registered.

Definition at line 193 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

00194    {
00195       return mSelectorImp.getNumHandles();
00196    }

template<class RealSelectorImp>
vpr::IOSys::Handle vpr::Selector_t< RealSelectorImp >::getHandle ( vpr::Uint16  index  )  [inline]

Gets the handle at the given index within the collection of registered handles.

The index is determined by the order of handle addition using addHandle().

Parameters:
index The index of the desired handle.
Returns:
A vpr::IOSys::Handle object representing the registered handle at the given index.

Definition at line 208 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

00209    {
00210       return mSelectorImp.getHandle(index);
00211    }

template<class RealSelectorImp>
bool vpr::Selector_t< RealSelectorImp >::containsHandle ( vpr::IOSys::Handle  handle  )  [inline]

Test if the selector contain the given handle.

Parameters:
handle The handle of interest.
Returns:
true is returned if handle was previously registered with this selector.

false is returned if the handle has not been registered.

Definition at line 222 of file Selector_t.h.

References vpr::Selector_t< RealSelectorImp >::mSelectorImp.

00223    {
00224       return mSelectorImp.containsHandle(handle);
00225    }


Member Data Documentation

template<class RealSelectorImp>
RealSelectorImp vpr::Selector_t< RealSelectorImp >::mSelectorImp [protected]

Platform-specific implementation.

Definition at line 228 of file Selector_t.h.

Referenced by vpr::Selector_t< RealSelectorImp >::addHandle(), vpr::Selector_t< RealSelectorImp >::containsHandle(), vpr::Selector_t< RealSelectorImp >::getHandle(), vpr::Selector_t< RealSelectorImp >::getIn(), vpr::Selector_t< RealSelectorImp >::getNumHandles(), vpr::Selector_t< RealSelectorImp >::getOut(), vpr::Selector_t< RealSelectorImp >::removeHandle(), vpr::Selector_t< RealSelectorImp >::select(), and vpr::Selector_t< RealSelectorImp >::setIn().


The documentation for this class was generated from the following file:
Generated on Thu Jan 4 10:55:10 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1