]> git.tdb.fi Git - libs/core.git/blobdiff - source/event.cpp
Rename to libmspcore
[libs/core.git] / source / event.cpp
diff --git a/source/event.cpp b/source/event.cpp
deleted file mode 100644 (file)
index 01b8542..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-This file is part of libmspframework
-Copyright © 2006 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-#ifdef WIN32
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-#include "application.h"
-#include "event.h"
-
-using namespace std;
-
-namespace Msp {
-
-EventManager::EventManager(Application &a):
-       app(a),
-       next_id(1)
-{
-       app.add_pollable(&pipe, POLLIN).signal_event.connect(sigc::mem_fun(this, &EventManager::data_available));
-}
-
-EventManager::Event &EventManager::create_event()
-{
-       events.push_back(Event(*this, next_id++));
-       return events.back();
-}
-
-void EventManager::data_available(short)
-{
-       unsigned buf[1024];
-       int len=pipe.read((char *)buf, sizeof(buf));
-       for(unsigned i=0; i*sizeof(unsigned)<(unsigned)len; ++i)
-       {
-               for(list<Event>::iterator j=events.begin(); j!=events.end(); ++j)
-                       if(j->get_id()==buf[i])
-                               j->signal_triggered.emit();
-       }
-}
-
-void EventManager::Event::trigger()
-{
-       mgr.pipe.write((char *)&id, sizeof(id));
-}
-
-EventManager::Pipe::Pipe()
-{
-#ifdef WIN32
-       _pipe(fd, 1024, _O_BINARY);
-#else
-       ::pipe(fd);
-#endif
-}
-
-int EventManager::Pipe::write(char *buf, unsigned len)
-{
-#ifdef WIN32
-       return _write(fd[1], buf, len);
-#else
-       return ::write(fd[1], buf, len);
-#endif
-}
-
-int EventManager::Pipe::read(char *buf, unsigned len)
-{
-#ifdef WIN32
-       return _read(fd[0], buf, len);
-#else
-       return ::read(fd[0], buf, len);
-#endif
-}
-
-} // namespace Msp