diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-08-10 02:58:35 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-08-10 02:58:35 -0700 |
commit | ec0f82bb6ea911baee6b9654f799f037282bf5b9 (patch) | |
tree | f18dd08e58c9231de3353544191c1fa2dfdbcb2b /src/HttpServer.cc | |
parent | bd06a6ec9ec3d0e10fe6e09bab4a156ceef6e0c8 (diff) |
Introducing notion of filters.
Diffstat (limited to 'src/HttpServer.cc')
-rw-r--r-- | src/HttpServer.cc | 17 |
1 files changed, 4 insertions, 13 deletions
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<Balau::Handle> 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<Balau::Handle> 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<Balau::Handle> m_h; Balau::String m_name; bool m_wrote; }; |