]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/sg_netChannel.hxx
Drop explicit SDK setting on Mac
[simgear.git] / simgear / io / sg_netChannel.hxx
index 6cadc1f308cc148219233a296e8120d985b37eef..538618c3f0187ef930d5d717dfd9d8a434dcdf72 100644 (file)
 #define SG_NET_CHANNEL_H
 
 #include <simgear/io/raw_socket.hxx>
+
 #include <string>
+#include <vector>
 
 namespace simgear
 {
 
+class NetChannelPoller;
+    
 class NetChannel : public Socket
 {
   bool closed, connected, accepting, write_blocked, should_delete, resolving_host ;
-  NetChannel* next_channel ;
   std::string host;
   int port;
   
-  friend bool netPoll (unsigned int timeout);
-
+    friend class NetChannelPoller;
+    NetChannelPoller* poller;
 public:
 
   NetChannel () ;
@@ -109,9 +112,21 @@ public:
   virtual void handleWrite (void);
   virtual void handleAccept (void);
   virtual void handleError (int error);
-  
-  static bool poll (unsigned int timeout = 0 ) ;
-  static void loop (unsigned int timeout = 0 ) ;
+
+};
+
+class NetChannelPoller
+{
+    typedef std::vector<NetChannel*> ChannelList;
+    ChannelList channels;
+public:
+    void addChannel(NetChannel* channel);
+    void removeChannel(NetChannel* channel);
+    
+    bool hasChannels() const { return !channels.empty(); }
+    
+    bool poll(unsigned int timeout = 0);
+    void loop(unsigned int timeout = 0);
 };
 
 } // of namespace simgear