00001 #ifndef CLASSLIB_IOSELECT_METHOD_H 00002 # define CLASSLIB_IOSELECT_METHOD_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "IOSelectRequest.h" 00007 # include "classlib/utils/DebugAids.h" 00008 # include <vector> 00009 00010 namespace lat { 00011 //<<<<<< PUBLIC DEFINES >>>>>> 00012 //<<<<<< PUBLIC CONSTANTS >>>>>> 00013 //<<<<<< PUBLIC TYPES >>>>>> 00014 //<<<<<< PUBLIC VARIABLES >>>>>> 00015 //<<<<<< PUBLIC FUNCTIONS >>>>>> 00016 //<<<<<< CLASS DECLARATIONS >>>>>> 00017 00019 class IOSelectMethod 00020 { 00021 public: 00022 virtual ~IOSelectMethod (void); 00023 00024 virtual void setSignal (int sig); 00025 00026 // Attaching and detaching descriptors 00027 virtual void attach (const IOSelectRequest &req) = 0; 00028 virtual void detach (const IOSelectRequest &req) = 0; 00029 virtual void clear (void) = 0; 00030 00031 // Descriptor listening states 00032 virtual void setMask (IOFD fd, unsigned value) = 0; 00033 virtual void andMask (IOFD fd, unsigned value) = 0; 00034 virtual void orMask (IOFD fd, unsigned value) = 0; 00035 00036 // Selection 00037 virtual bool wait (long msecs) = 0; 00038 virtual IOFD next (IOSelectEvent &event, IOSelectCB &cb) = 0; 00039 00040 // Methods for IOSelector and actual implementations 00041 size_t requests (void); 00042 00043 protected: 00044 // Methods for actual implementations 00045 IOSelectRequest & request (size_t index); 00046 // size_t findReq (IOFD fd); 00047 size_t addReq (const IOSelectRequest &req); 00048 void removeReq (const IOSelectRequest &req, size_t index); 00049 // void removeReq (const IOSelectRequest &req); 00050 void clearReqs (void); 00051 00052 private: 00053 std::vector<IOSelectRequest> m_requests; //< Current requests. 00054 }; 00055 00056 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> 00057 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>> 00058 00059 inline size_t 00060 IOSelectMethod::requests (void) 00061 { return m_requests.size (); } 00062 00063 inline IOSelectRequest & 00064 IOSelectMethod::request (size_t index) 00065 { 00066 ASSERT (index < m_requests.size ()); 00067 return m_requests [index]; 00068 } 00069 00070 } // namespace lat 00071 #endif // CLASSLIB_IOSELECT_METHOD_H