#ifndef TOOLBOX_SELECT_H
#define TOOLBOX_SELECT_H

#include "clist.h" 

#include <sys/types.h>

class cTBSelect {
private:
	int    m_MaxFiled;

	fd_set m_Rfds;
	fd_set m_Wfds;

public:
	cTBSelect(void);
	virtual ~cTBSelect();

	virtual void Clear(void);
	virtual void Add(int Filed, bool Output = false);

	virtual bool CanRead(int FileNo) const;
	virtual bool CanWrite(int FileNo) const;

	virtual int Select(int TimeoutMs = 0);
};

inline bool cTBSelect::CanRead(int FileNo) const {
	return FD_ISSET(FileNo, &m_Rfds);
}

inline bool cTBSelect::CanWrite(int FileNo) const {
	return FD_ISSET(FileNo, &m_Wfds);
}

#endif // TOOLBOX_SELECT_H
