InetTransportManager.h

00001 /* Open SoundControl kit in C++                                              */
00002 /* Copyright (C) 2002-2004 libOSC++ contributors. See AUTHORS                */
00003 /*                                                                           */
00004 /* This library is free software; you can redistribute it and/or             */
00005 /* modify it under the terms of the GNU Lesser General Public                */
00006 /* License as published by the Free Software Foundation; either              */
00007 /* version 2.1 of the License, or (at your option) any later version.        */
00008 /*                                                                           */
00009 /* This library is distributed in the hope that it will be useful,           */
00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         */
00012 /* Lesser General Public License for more details.                           */
00013 /*                                                                           */
00014 /* You should have received a copy of the GNU Lesser General Public          */
00015 /* License along with this library; if not, write to the Free Software       */
00016 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00017 /*                                                                           */
00018 /* For questions regarding this program contact                              */
00019 /* Daniel Holth <dholth@fastmail.fm> or visit                                */
00020 /* http://wiretap.stetson.edu/                                               */
00021 
00037 /*
00038  * this class was written by Martin Rumori (martin@rumori.de)
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

Generated on Thu Mar 2 23:51:35 2006 for libOSC++ by  doxygen 1.4.6