00001 // $Id: FdEvent.cci 1781 2011-04-11 12:10:19Z tho $ 00002 // 00003 // Copyright (C) 2008 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #include "FdEvent.ih" 00027 00028 // Custom includes 00029 #include "FdManager.hh" 00030 00031 #define prefix_ inline 00032 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00033 00034 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00035 // senf::scheduler::FdEvent 00036 00037 prefix_ senf::scheduler::FdEvent::FdEvent(std::string const & name, Callback const & cb) 00038 : detail::FIFORunner::TaskInfo (name), cb_ (cb), fd_ (-1), pollable_ (true), events_ (0) 00039 {} 00040 00041 prefix_ senf::scheduler::FdEvent::~FdEvent() 00042 { 00043 if (detail::FdDispatcher::alive()) 00044 disable(); 00045 } 00046 00047 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::action(Callback const & cb) 00048 { 00049 cb_ = cb; 00050 return *this; 00051 } 00052 00053 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::addEvents(int e) 00054 { 00055 events( events() | e ); 00056 return *this; 00057 } 00058 00059 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::removeEvents(int e) 00060 { 00061 events( events() & ~e ); 00062 return *this; 00063 } 00064 00065 prefix_ int senf::scheduler::FdEvent::events() 00066 { 00067 return events_; 00068 } 00069 00070 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00071 // senf::scheduler::detail::FdDispatcher 00072 00073 prefix_ senf::scheduler::detail::FdDispatcher::FdDispatcher() 00074 {} 00075 00076 prefix_ bool senf::scheduler::detail::FdDispatcher::empty() 00077 const 00078 { 00079 return fds_.empty(); 00080 } 00081 00082 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00083 // senf::scheduler::detail::FileDispatcher 00084 00085 prefix_ void senf::scheduler::detail::FileDispatcher::timeout(int t) 00086 { 00087 managerTimeout_ = t; 00088 if (fds_.empty()) 00089 detail::FdManager::instance().timeout(managerTimeout_); 00090 } 00091 00092 prefix_ int senf::scheduler::detail::FileDispatcher::timeout() 00093 const 00094 { 00095 return managerTimeout_; 00096 } 00097 00098 prefix_ bool senf::scheduler::detail::FileDispatcher::empty() 00099 const 00100 { 00101 return fds_.empty(); 00102 } 00103 00104 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00105 00106 prefix_ int senf::scheduler::detail::retrieve_filehandle(int fd) 00107 { 00108 return fd; 00109 } 00110 00111 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00112 #undef prefix_ 00113 00114 00115 // Local Variables: 00116 // mode: c++ 00117 // fill-column: 100 00118 // comment-column: 40 00119 // c-file-style: "senf" 00120 // indent-tabs-mode: nil 00121 // ispell-local-dictionary: "american" 00122 // compile-command: "scons -u test" 00123 // End: