X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Scheduler%2FWriteHelper.ct;h=2fa26020aca199ab7786dc6768caa8410ad92973;hb=9a988902090d28007578e93bffd809f6bd913155;hp=8ef626da982856c34c621a56bf494976c6102e80;hpb=c5ab87643518405aa5171ed4602f7234873a4900;p=senf.git diff --git a/Scheduler/WriteHelper.ct b/Scheduler/WriteHelper.ct index 8ef626d..2fa2602 100644 --- a/Scheduler/WriteHelper.ct +++ b/Scheduler/WriteHelper.ct @@ -1,8 +1,25 @@ // $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2006 Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// Copyright (C) 2006 -// Definition of non-inline template functions +/** \file + \brief WriteHelper non-inline template implementation */ //#include "WriteHelper.ih" @@ -15,39 +32,39 @@ ///////////////////////////////ct.p//////////////////////////////////////// template -prefix_ satcom::lib::WriteHelper::WriteHelper(Handle handle, std::string data, +prefix_ senf::WriteHelper::WriteHelper(Handle handle, std::string data, Callback callback) : handle_(handle), data_(data), callback_(callback), offset_(0), errno_(0) { - satcom::lib::Scheduler::instance() - .add(handle_, boost::bind(&WriteHelper::dispatchProcess, ptr(this), _1, _2), - satcom::lib::Scheduler::EV_WRITE); + senf::Scheduler::instance() + .add(handle_, boost::bind(&WriteHelper::dispatchProcess, ptr(this), _1, _2), + senf::Scheduler::EV_WRITE); } template -prefix_ std::string const & satcom::lib::WriteHelper::data() +prefix_ std::string const & senf::WriteHelper::data() const { if (offset_ > 0) { - data_.erase(0,offset_); - offset_ = 0; + data_.erase(0,offset_); + offset_ = 0; } return data_; } template -prefix_ void satcom::lib::WriteHelper::revoke() +prefix_ void senf::WriteHelper::revoke() { ptr guard (this); // To ensure, 'this' is deleted only after this method terminates ... - satcom::lib::Scheduler::instance() - .remove(handle_, satcom::lib::Scheduler::EV_WRITE); + senf::Scheduler::instance() + .remove(handle_, senf::Scheduler::EV_WRITE); } template prefix_ void -satcom::lib::WriteHelper::dispatchProcess(ptr helper, Handle handle, - satcom::lib::Scheduler::EventId event) +senf::WriteHelper::dispatchProcess(ptr helper, Handle handle, + senf::Scheduler::EventId event) { // since we have a 'ptr' argument, the instance cannot be deleted // before this method returns @@ -55,26 +72,27 @@ satcom::lib::WriteHelper::dispatchProcess(ptr helper, Handle handle, } template -prefix_ void satcom::lib::WriteHelper::process(Handle handle, - satcom::lib::Scheduler::EventId event) +prefix_ void senf::WriteHelper::process(Handle handle, + senf::Scheduler::EventId event) { + /** \fixme Move the done() calls to outside the try/catch block */ try { - if (event != satcom::lib::Scheduler::EV_WRITE) - throw satcom::lib::SystemException(EPIPE); - offset_ += handle.write(data_.data()+offset_,data_.size()-offset_); - if (offset_ >= data_.size()) { - data_.erase(); - done(); - } + if (event != senf::Scheduler::EV_WRITE) + throw senf::SystemException(EPIPE); + offset_ += handle.write(data_.data()+offset_,data_.size()-offset_); + if (offset_ >= data_.size()) { + data_.erase(); + done(); + } } - catch (satcom::lib::SystemException const & ex) { - errno_ = ex.err; - done(); + catch (senf::SystemException const & ex) { + errno_ = ex.err; + done(); } } template -prefix_ void satcom::lib::WriteHelper::done() +prefix_ void senf::WriteHelper::done() { revoke(); callback_(ptr(this)); @@ -86,4 +104,8 @@ prefix_ void satcom::lib::WriteHelper::done() // Local Variables: // mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" // End: