WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_13.html taken on Sat Jun 10 19:13:40 1995

Go to the previous, next section.

FDSet--Set of File Descriptors

SYNOPSIS

#include <nihcl/FDSet.h>

BASE CLASS

Object

DERIVED CLASSES

None

RELATED CLASSES

None

DESCRIPTION

Instances of class FDSet provide a representation of a set of file descriptors suitable for use with the select() UNIX operating system call. Each bit in an FDset corresponds to a UNIX file descriptor of the same number; for example, bit 0 corresponds to file descriptor 0, bit 1 to file descriptor 1, and so on. If a bit is 1, then its corresponding file descriptor is considered to be a member of the FDSet.

Class FDSet provides member functions for setting, clearing, or testing individual bits, a complete set of logical operators for combining FDSets, conversion operators so that instances of class FDSet can be passed as arguments to select(), and index operators so that the bits in an FDSet can be referenced using index notation.

STATIC MEMBER FUNCTIONS

static unsigned dtablesize()
Returns the size of the file descriptor table for the current process. This is the maximum number of bits in an FDSet.

CONSTRUCTORS

FDSet()
Creates an instance of class FDSet initialized to all zeros.

ACCESSING FDSETS

void clr(int fd)
void set(int fd)
Clears or sets the bit in this FDSet that corresponds to the argument file descriptor number fd. File descriptors are numbered starting with zero.

void zero()
Sets all the bits in this FDSet to zero.

SEARCHING

virtual unsigned hash() const
Returns a number suitable for use as a hash table probe.

RELATIONAL OPERATORS

bool operator==(const FDSet&) const
bool operator!=(const FDSet&) const
Returns YES if the left FDSet operand is equal to (or not equal to) the right FDSet operand.

LOGICAL OPERATORS

FDSet operator-(const FDSet&) const
Returns an FDSet that contains all integers that are in the left FDSet operand and not in the right FDSet operand. For example, FDSet(0,1,2) - FDSet(1,2) is the FDSet [0].

FDSet operator&(const FDSet&) const
Returns an FDSet containing all integers that are in both the left and right FDSet operands. For example, FDSet(0,1) & FDSet(1,2) is the FDSet [1].

FDSet operator|(const FDSet&) const
Returns an FDSet containing all integers that are in either the left or right FDSet operands. For example, FDSet(0,1) | FDSet(1,2) is the FDSet [0,1,2].

FDSet operator^(const FDSet&) const
Returns an FDSet containing all integers that are in the left or right FDSet operands, but not in both. For example, FDSet(0,1) ^ FDSet(1,2) is the FDSet [0,2].

void operator-=(const FDSet&)
void operator&=(const FDSet&)
void operator|=(const FDSet&)
void operator^=(const FDSet&)
Replaces the left FDSet operand by the result of applying the indicated logical operation to the left and right FDSet operands.

TESTING FDSETS

bool includes(unsigned fd) const
bool isSet(int fd) const
Returns YES if fd is a member of this FDSet; that is, if bit fd of this FDSet is one.

virtual bool isEmpty() const
Returns YES if all bits in this FDSet are zero.

virtual bool isEqual(const Object& ob) const
Returns YES if ob is of species FDSet and equals this FDSet.

CONVERTING FDSETS

operator fd_set&()
operator const fd_set&() const
operator fd_set*()
operator const fd_set*() const
Returns a reference or pointer to a file descriptor set (type fd_set), suitable for use as an argument to the select() system call.

COPYING FDSETS

virtual void deepenShallowCopy()
This function is a no-op for class FDSet.

INDEXING FDSETS

FDSetRef operator[](int fd)
const FDSetRef operator[](int fd) const
Returns an instance of the private class FDSetRef, which allows the bit corresponding to file descriptor fd to be accessed. For example,

FDSet s;
s[2] = 1;

sets the bit corresponding to file descriptor 2 in the FDSet s to 1, and

FDSet s;
if (s[2]) // ...

tests the bit corresponding to file descriptor 2 in the FDSet s.

FDSET CAPACITY AND SIZE

virtual unsigned capacity() const
Returns the size of the file descriptor table for the current process.

virtual unsigned size() const
Returns the number of 1 bits in this FDSet.

READING AND PRINTING FDSETS

virtual void printOn(ostream& strm =cout) const
Prints a comma separated list of the file descriptor numbers that are members of this FDSet on output stream strm.

FDSET SPECIES

virtual const Class* species() const
Returns a pointer to the class descriptor for class FDSet.

PROTECTED MEMBERS

Object I/O

virtual void storer(OIOofd& fd) const
virtual void storer(OIOout& strm) const
Stores this FDSet on fd or strm.

DISABLED MEMBER FUNCTIONS

virtual int compare(const Object&) const
These functions are implemented as shouldNotImplement().

EXCEPTIONS RAISED

None

Go to the previous, next section.