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
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

AreaRegistry.cci

Go to the documentation of this file.
00001 // $Id: AreaRegistry.cci 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
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 "AreaRegistry.ih"
00027 
00028 // Custom includes
00029 #include <senf/Utils/TypeInfo.hh>
00030 #include "Levels.hh"
00031 #include "StreamRegistry.hh"
00032 
00033 #define prefix_ inline
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 // senf::log::AreaRegistry
00038 
00039 prefix_ std::string const &
00040 senf::log::AreaRegistry::SelectName::operator()(Registry::value_type const & v)
00041     const
00042 {
00043     return v.first;
00044 }
00045 
00046 prefix_ senf::log::AreaRegistry::AreaRegistry()
00047 {}
00048 
00049 prefix_ senf::log::AreaRegistry::iterator senf::log::AreaRegistry::begin()
00050 {
00051     return boost::make_transform_iterator(registry_.begin(), SelectName());
00052 }
00053 
00054 prefix_ senf::log::AreaRegistry::iterator senf::log::AreaRegistry::end()
00055 {
00056     return boost::make_transform_iterator(registry_.end(), SelectName());
00057 }
00058 
00059 prefix_ void senf::log::AreaRegistry::registerArea(detail::AreaBase const & area)
00060 {
00061     registry_.insert( std::make_pair(area.v_name(), &area) );
00062 }
00063 
00064 prefix_ senf::log::detail::AreaBase const *
00065 senf::log::AreaRegistry::lookup(std::string const & name)
00066 {
00067     Registry::iterator i (registry_.find(name));
00068     return i == registry_.end() ? 0 : i->second;
00069 }
00070 
00071 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00072 // senf::log::detail::AreaBase
00073 
00074 prefix_ std::string senf::log::detail::AreaBase::fullName()
00075     const
00076 {
00077     return prettyName(typeid(*this));
00078 }
00079 
00080 prefix_ std::string senf::log::detail::AreaBase::v_name()
00081     const
00082 {
00083     return fullName();
00084 }
00085 
00086 prefix_ void senf::log::detail::AreaBase::init()
00087 {
00088     senf::log::AreaRegistry::instance().registerArea(*this);
00089 }
00090 
00091 prefix_ bool senf::log::detail::AreaBase::alive()
00092     const
00093 {
00094     return alive_;
00095 }
00096 
00097 prefix_ unsigned senf::log::detail::AreaBase::limit(StreamBase const & stream)
00098     const
00099 {
00100     return stream.index >= routingCache_.size() ?
00101         DISABLED::value : routingCache_[stream.index].limit;
00102 }
00103 
00104 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00105 #undef prefix_
00106 
00107 
00108 // Local Variables:
00109 // mode: c++
00110 // fill-column: 100
00111 // comment-column: 40
00112 // c-file-style: "senf"
00113 // indent-tabs-mode: nil
00114 // ispell-local-dictionary: "american"
00115 // compile-command: "scons -u test"
00116 // End:

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