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.cc

Go to the documentation of this file.
00001 // $Id: AreaRegistry.cc 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.hh"
00027 #include "AreaRegistry.ih"
00028 
00029 // Custom includes
00030 #include "Target.hh"
00031 
00032 //#include "AreaRegistry.mpp"
00033 #define prefix_
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 // senf::log::detail::AreaBase
00038 
00039 prefix_ senf::log::detail::AreaBase::AreaBase()
00040     : alive_ (true)
00041 {}
00042 
00043 prefix_ senf::log::detail::AreaBase::~AreaBase()
00044 {
00045     alive_ = false;
00046 }
00047 
00048 prefix_ void senf::log::detail::AreaBase::updateRoutingCache(Target & target,
00049                                                              StreamBase const & stream,
00050                                                              unsigned limit)
00051     const
00052 {
00053     if (stream.index >= routingCache_.size())
00054         routingCache_.resize(stream.index+1);
00055     unsigned l (limit);
00056     Routes::iterator i (routingCache_[stream.index].routes.begin());
00057     Routes::iterator const i_end (routingCache_[stream.index].routes.end());
00058     for (; i != i_end; ++i) {
00059         if (i->target == &target) {
00060             i->limit = limit;
00061             break;
00062         }
00063         if (i->limit < l)
00064             l = i->limit;
00065     }
00066     if (i == i_end)
00067         routingCache_[stream.index].routes.push_back(RouteEntry(limit, &target));
00068     else
00069         for (; i != i_end; ++i)
00070             if (i->limit < l)
00071                 l = i->limit;
00072     routingCache_[stream.index].limit = l;
00073 }
00074 
00075 prefix_ void senf::log::detail::AreaBase::removeRoutingCache(Target & target,
00076                                                              StreamBase const & stream)
00077     const
00078 {
00079     if (stream.index >= routingCache_.size())
00080         return;
00081     unsigned l (DISABLED::value);
00082     Routes::iterator i (routingCache_[stream.index].routes.begin());
00083     Routes::iterator const i_end (routingCache_[stream.index].routes.end());
00084     while (i != i_end) {
00085         if (i->target == &target)
00086             i = routingCache_[stream.index].routes.erase(i);
00087         else {
00088             if (i->limit < l)
00089                 l = i->limit;
00090             ++i;
00091         }
00092     }
00093     routingCache_[stream.index].limit = l;
00094 }
00095 
00096 prefix_ void senf::log::detail::AreaBase::write(time_type timestamp,
00097                                                 StreamBase const & stream, unsigned level,
00098                                                 std::string const & msg)
00099     const
00100 {
00101     if (stream.index >= routingCache_.size())
00102         return;
00103     Routes::iterator i (routingCache_[stream.index].routes.begin());
00104     Routes::iterator const i_end (routingCache_[stream.index].routes.end());
00105     for (; i != i_end; ++i)
00106         i->target->write(timestamp, stream, *this, level, msg);
00107 }
00108 
00109 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00110 #undef prefix_
00111 //#include "AreaRegistry.mpp"
00112 
00113 
00114 // Local Variables:
00115 // mode: c++
00116 // fill-column: 100
00117 // comment-column: 40
00118 // c-file-style: "senf"
00119 // indent-tabs-mode: nil
00120 // ispell-local-dictionary: "american"
00121 // compile-command: "scons -u test"
00122 // End:

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