Loading...
Searching...
No Matches
FdSet.h
Go to the documentation of this file.
// -*- c++ -*-
//------------------------------------------------------------------------------
// FdSet.h
//------------------------------------------------------------------------------
// Copyright (C) 1997-2002 Vladislav Grinchenko
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef FDSET_H
#define FDSET_H
#include <string.h>
#include <sys/time.h> /* select(3) */
#if defined(Linux) /* select(3) */
# include <sys/types.h>
# include <unistd.h>
#endif
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <list>
#include "assa/Logger.h"
namespace ASSA {
class FdSet : public fd_set
{
public:
FdSet ();
bool setFd (handler_t fd_);
bool clear (handler_t fd_);
bool isSet (handler_t fd_);
void sync ();
void reset ();
int maxInSet ();
int numSet ();
void dump ();
std::string dump_c_str ();
private:
#if !defined (WIN32)
typedef std::list<u_int>::iterator ActiveFDs_Iter;
std::list<u_int> m_actfds;
#endif
};
//------------------------------------------------------------------------------
// Member Functions
//------------------------------------------------------------------------------
inline FdSet::FdSet () { reset (); }
inline void FdSet::dump () { DL ((REACT, "%s\n", dump_c_str ().c_str ())); }
inline bool FdSet::isSet (handler_t fd_) { return FD_ISSET (fd_, this); }
inline int
FdSet::
numSet ()
{
#if defined (WIN32)
return this->fd_count;
#else /* UNIX */
return m_actfds.size ();
#endif
}
} // end namespace ASSA
#endif /* FDSET_H */
Logger.h
An abstraction to message logging facility.
DL
#define DL(X)
A macro for writing debug message to the Logger.
Definition Logger.h:273
handler_t
int handler_t
Definition Logger_Impl.h:82
ASSA::AutoPtrRef
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
ASSA::FdSet
Class FdSet.
Definition FdSet.h:52
ASSA::FdSet::ActiveFDs_Iter
std::list< u_int >::iterator ActiveFDs_Iter
Definition FdSet.h:110
ASSA::FdSet::m_actfds
std::list< u_int > m_actfds
Definition FdSet.h:112
ASSA::FdSet::reset
void reset()
Reset every bit in the set (OFF).
Definition FdSet.cpp:90
ASSA::FdSet::setFd
bool setFd(handler_t fd_)
Set flag (ON) for the argument fd.
Definition FdSet.cpp:20
ASSA::FdSet::sync
void sync()
Sync internals after used by select(3C)
Definition FdSet.cpp:72
ASSA::FdSet::dump_c_str
std::string dump_c_str()
Return object state dump as an ASCII string.
Definition FdSet.cpp:116
ASSA::FdSet::maxInSet
int maxInSet()
Find out the highest file descriptor in the set.
Definition FdSet.cpp:101
ASSA::FdSet::FdSet
FdSet()
Constructor.
Definition FdSet.h:119
ASSA::FdSet::dump
void dump()
Determine highest handler in the set.
Definition FdSet.h:120
ASSA::FdSet::isSet
bool isSet(handler_t fd_)
Test whether fd's flag is on.
Definition FdSet.h:122
ASSA::FdSet::clear
bool clear(handler_t fd_)
Clear flag (OFF) for the argument fd.
Definition FdSet.cpp:39
ASSA::FdSet::numSet
int numSet()
Determine how many bits are set (ON) in the set.
Definition FdSet.h:126
ASSA
Definition Acceptor.h:40
ASSA::REACT
@ REACT
Class Reactor/PrioriyQueue messages
Definition LogMask.h:39