Pimpl SocketManager class
[yazpp-moved-to-github.git] / include / yazpp / socket-manager.h
index b56feea..87e828d 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the yazpp toolkit.
- * Copyright (C) 1998-2011 Index Data and Mike Taylor
+ * Copyright (C) 1998-2012 Index Data and Mike Taylor
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -29,7 +29,6 @@
 #define YAZ_SOCKET_MANAGER_INCLUDED
 
 #include <yazpp/socket-observer.h>
-#include <time.h>
 
 struct yaz_poll_fd;
 namespace yazpp_1 {
@@ -40,31 +39,16 @@ namespace yazpp_1 {
 */
 class YAZ_EXPORT SocketManager : public ISocketObservable {
  private:
-    struct SocketEntry {
-        ISocketObserver *observer;
-        int fd;
-        unsigned mask;
-        int timeout;
-        int timeout_this;
-        time_t last_activity;
-        SocketEntry *next;
-    };
-    SocketEntry *m_observers;       // all registered observers
-    struct SocketEvent {
-        ISocketObserver *observer;
-        int event;
-        SocketEvent *next;          // front in queue
-        SocketEvent *prev;          // back in queue
-    };
-    SocketEvent *m_queue_front;
-    SocketEvent *m_queue_back;
-    
-    SocketEntry **lookupObserver
-        (ISocketObserver *observer);
+    struct SocketEntry;
+    struct SocketEvent;
+    struct Rep;
+
+    Rep *m_p;
+
+    SocketEntry **lookupObserver(ISocketObserver *observer);
     SocketEvent *getEvent();
     void putEvent(SocketEvent *event);
     void removeEvent(ISocketObserver *observer);
-    int m_log;
     void inspect_poll_result(int res, struct yaz_poll_fd *fds, int no_fds,
                              int timeout);
  public:
@@ -81,6 +65,7 @@ class YAZ_EXPORT SocketManager : public ISocketObservable {
                                  int timeout);
     /// Process one event. return > 0 if event could be processed;
     int processEvent();
+    int getNumberOfObservers();
     SocketManager();
     virtual ~SocketManager();
 };