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

StreamRegistry.cci

Go to the documentation of this file.
00001 // $Id: StreamRegistry.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 "StreamRegistry.ih"
00027 
00028 // Custom includes
00029 #include <senf/Utils/TypeInfo.hh>
00030 
00031 #define prefix_ inline
00032 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00033 
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 // senf::log::StreamRegistry
00036 
00037 prefix_ senf::log::StreamRegistry::StreamRegistry()
00038 {}
00039 
00040 prefix_ senf::log::StreamRegistry::iterator senf::log::StreamRegistry::begin()
00041 {
00042     return boost::make_transform_iterator(registry_.begin(),
00043                                           ::__gnu_cxx::select1st<Registry::value_type>());
00044 }
00045 
00046 prefix_ senf::log::StreamRegistry::iterator senf::log::StreamRegistry::end()
00047 {
00048     return boost::make_transform_iterator(registry_.end(),
00049                                           ::__gnu_cxx::select1st<Registry::value_type>());
00050 }
00051 
00052 prefix_ void senf::log::StreamRegistry::registerStream(detail::StreamBase const & stream)
00053 {
00054     registry_.insert( std::make_pair(stream.v_name(), &stream) );
00055 }
00056 
00057 prefix_ senf::log::detail::StreamBase const *
00058 senf::log::StreamRegistry::lookup(std::string const & name)
00059 {
00060     Registry::iterator i (registry_.find(name));
00061     return i == registry_.end() ? 0 : i->second;
00062 }
00063 
00064 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00065 // senf::log::detail::StreamBase
00066 
00067 prefix_ senf::log::detail::StreamBase::StreamBase()
00068     : index( nStreams++ )
00069 {}
00070 
00071 prefix_ std::string senf::log::detail::StreamBase::fullName()
00072     const
00073 {
00074     return prettyName(typeid(*this));
00075 }
00076 
00077 prefix_ std::string senf::log::detail::StreamBase::v_name()
00078     const
00079 {
00080     return fullName();
00081 }
00082 
00083 prefix_ void senf::log::detail::StreamBase::init()
00084 {
00085     senf::log::StreamRegistry::instance().registerStream(*this);
00086 }
00087 
00088 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00089 #undef prefix_
00090 
00091 
00092 // Local Variables:
00093 // mode: c++
00094 // fill-column: 100
00095 // comment-column: 40
00096 // c-file-style: "senf"
00097 // indent-tabs-mode: nil
00098 // ispell-local-dictionary: "american"
00099 // compile-command: "scons -u test"
00100 // End:

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