Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

EventManager.cci

Go to the documentation of this file.
00001 // $Id: EventManager.cci 1742 2010-11-04 14:51:56Z g0dil $
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 "EventManager.ih"
00027 
00028 // Custom includes
00029 
00030 #define prefix_ inline
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 // senf::scheduler::detail::Event
00035 
00036 prefix_ senf::scheduler::detail::Event::Event(std::string const & name)
00037     : name_ (name), runCount_ (0u)
00038 {
00039     EventManager::instance().add(*this);
00040 }
00041 
00042 prefix_ senf::scheduler::detail::Event::~Event()
00043 {
00044     EventManager::instance().remove(*this);
00045 }
00046 
00047 prefix_ void senf::scheduler::detail::EventManager::add(Event & event)
00048 {
00049     events_.push_back(event);
00050 }
00051 
00052 prefix_ void senf::scheduler::detail::EventManager::remove(Event & event)
00053 {
00054     events_.erase(EventList::current(event));
00055 }
00056 
00057 prefix_ std::string const & senf::scheduler::detail::Event::name()
00058     const
00059 {
00060     return name_;
00061 }
00062 
00063 prefix_ bool senf::scheduler::detail::Event::enabled()
00064     const
00065 {
00066     return v_enabled();
00067 }
00068 
00069 prefix_ unsigned senf::scheduler::detail::Event::runCount()
00070     const
00071 {
00072     return runCount_;
00073 }
00074 
00075 prefix_ char const * senf::scheduler::detail::Event::type()
00076     const
00077 {
00078     return v_type();
00079 }
00080 
00081 prefix_ std::string senf::scheduler::detail::Event::info()
00082     const
00083 {
00084     return v_info();
00085 }
00086 
00087 prefix_ void senf::scheduler::detail::Event::countRun()
00088 {
00089     ++ runCount_;
00090 }
00091 
00092 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00093 // senf::scheduler::detail::EventManager
00094 
00095 prefix_ bool senf::scheduler::detail::EventManager::IteratorFilter::operator()(Event const & e)
00096 {
00097     return e.type() != 0;
00098 }
00099 
00100 prefix_ senf::scheduler::detail::EventManager::iterator
00101 senf::scheduler::detail::EventManager::begin()
00102     const
00103 {
00104     // We need to filter out elements with e.type() == 0 ... the NullTask temporarily added
00105     // by the FIFORunner is such an element and must be skipped.
00106     return boost::make_filter_iterator(
00107         IteratorFilter(), events_.begin(), events_.end());
00108 }
00109 
00110 prefix_ senf::scheduler::detail::EventManager::iterator
00111 senf::scheduler::detail::EventManager::end()
00112     const
00113 {
00114     return boost::make_filter_iterator(
00115         IteratorFilter(), events_.end(), events_.end());
00116 }
00117 
00118 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00119 #undef prefix_
00120 
00121 
00122 // Local Variables:
00123 // mode: c++
00124 // fill-column: 100
00125 // comment-column: 40
00126 // c-file-style: "senf"
00127 // indent-tabs-mode: nil
00128 // ispell-local-dictionary: "american"
00129 // compile-command: "scons -u test"
00130 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research