]> git.tdb.fi Git - libs/core.git/blobdiff - source/eventdispatcher.h
Move class members and comments around
[libs/core.git] / source / eventdispatcher.h
index 9bea6d2140943f014857a7bd1ee5d629add232e7..7e89d4739e845f0e0c180845ffedb43184eefd9f 100644 (file)
@@ -1,13 +1,8 @@
-/* $Id$
-
-This file is part of libmspio
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
 #ifndef EVENTDISPATCHER_H_
 #define EVENTDISPATCHER_H_
 
 #include <sigc++/connection.h>
+#include <sigc++/trackable.h>
 #include "poll.h"
 
 namespace Msp {
@@ -17,18 +12,8 @@ namespace IO {
 Put your I/O objects inside one of these to get signaled when something happens
 on some of them.
 */
-class EventDispatcher
+class EventDispatcher: public sigc::trackable
 {
-public:
-       EventDispatcher();
-       void add(Base &);
-       void remove(Base &);
-
-       /**
-       Checks for and dispatches events.  If block is true, will block until events
-       are available.
-       */
-       void tick(bool =true);
 private:
        struct Slot
        {
@@ -38,13 +23,30 @@ private:
 
                Slot(Base *o): obj(o) { }
        };
+
        typedef std::map<Base *, Slot> SlotMap;
 
        Poller poller;
        SlotMap objects;
 
+public:
+       EventDispatcher();
+
+       void add(Base &);
+       void remove(Base &);
+
+       /** Checks for and dispatches events.  If there are no events available,
+       blocks until there are. */
+       void tick();
+
+       /** Checks for and dispatches events.  If there are no events available,
+       waits at most the specified time before returning. */
+       void tick(const Time::TimeDelta &);
+
+private:
        void object_events_changed(PollEvent, Base *);
        void object_deleted(Base *);
+       void dispatch();
 };
 
 } // namespace IO