00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00037
00038
00039
00040
00041 #ifndef LIBOSC_INETTRANSPORTMANAGER_H
00042 #define LIBOSC_INETTRANSPORTMANAGER_H
00043
00044 #include "ServiceManager.h"
00045 #include "InetTransport.h"
00046
00047 #ifdef __CYGWIN__
00048 #include <w32api/winsock2.h>
00049
00050 #else // __CYGWIN__
00051 #include <unistd.h>
00052 #include <sys/poll.h>
00053 #include <sys/types.h>
00054 #include <sys/time.h>
00055 #endif // __CYGWIN__
00056 #include <errno.h>
00057
00058 #include <map>
00059 #include <vector>
00060
00061
00062 class InetTransportManager : public ServiceManager
00063 {
00064
00065 public:
00067 InetTransportManager ();
00068
00070 virtual ~InetTransportManager ();
00071
00080 void serveForever ();
00081
00091 void runCycle ();
00092
00104 void runCycle (const int timeout);
00105
00110 void addInetTransport (InetTransport *const itrans);
00111
00116 void delInetTransport (InetTransport *const itrans);
00117
00129 void addService (Service *const service);
00130
00142 void delService (Service *const service);
00143
00152 void getTransports (std::vector<InetTransport *>& transports) const;
00153
00154
00155 protected:
00162 bool addHandleToPollfd (const int handle);
00163
00170 bool delHandleFromPollfd (const int handle);
00171
00174 void showState ();
00175
00178 void validatePollfd ();
00179
00180
00181 private:
00183 typedef std::map < int, InetTransport *, std::less<int> > InetTransportMap;
00184
00186 InetTransportMap _itrans;
00187
00189 struct pollfd *_pollfd;
00190
00192 int _pollnum;
00193
00194 };
00195
00196 #endif // #ifndef LIBOSC_INETTRANSPORTMANAGER_H