From ec0f82bb6ea911baee6b9654f799f037282bf5b9 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 10 Aug 2014 02:58:35 -0700 Subject: Introducing notion of filters. --- src/HttpServer.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/HttpServer.cc') diff --git a/src/HttpServer.cc b/src/HttpServer.cc index b0d4d2a..29571c6 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -11,27 +11,18 @@ #undef ERROR #endif -class OutputCheck : public Balau::Handle { +class OutputCheck : public Balau::Filter { public: - OutputCheck(Balau::IO h) : m_h(h), m_wrote(false) { IAssert(m_h->canWrite(), "We haven't been passed a writable Handle to our HttpWorker... ?"); m_name.set("OutputCheck(%s)", m_h->getName()); } - virtual void close() throw (Balau::GeneralException) { m_h->close(); } - virtual bool isClosed() { return m_h->isClosed(); } - virtual bool isEOF() { return m_h->isEOF(); } - virtual bool canWrite() { return true; } - virtual bool canRead() { return m_h->canRead(); } - virtual const char * getName() { return m_name.to_charp(); } + OutputCheck(Balau::IO h) : Filter(h), m_wrote(false) { IAssert(h->canWrite(), "We haven't been passed a writable Handle to our HttpWorker... ?"); m_name.set("OutputCheck(%s)", h->getName()); } virtual ssize_t write(const void * buf, size_t count) throw (Balau::GeneralException) { if (!count) return 0; m_wrote = true; - return m_h->write(buf, count); - } - virtual ssize_t read(void * buf, size_t count) throw (Balau::GeneralException) { - return m_h->read(buf, count); + return Filter::write(buf, count); } + virtual const char * getName() { return m_name.to_charp(); } bool wrote() { return m_wrote; } private: - Balau::IO m_h; Balau::String m_name; bool m_wrote; }; -- cgit v1.2.3