// $Id$
//
-// Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Copyright (C) 2007
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
/** \file
\brief Target inline non-template implementation */
-//#include "Target.ih"
+#include "Target.ih"
// Custom includes
-#include <algorithm>
+#include "AreaRegistry.hh"
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// senf::log::Target
-prefix_ void senf::log::Target::route(std::string const & stream, action_t action)
+prefix_ void senf::log::Target::route(action_t action, int index)
{
- detail::StreamBase const * s (StreamRegistry::instance().lookup(stream));
- if (!s)
- throw InvalidStreamException();
- route(s, 0, NONE::value, action);
+ route(0, 0, NONE::value, action, index);
}
-prefix_ void senf::log::Target::route(std::string const & stream, std::string const & area,
- action_t action)
+prefix_ void senf::log::Target::unroute(action_t action)
{
- detail::StreamBase const * s (StreamRegistry::instance().lookup(stream));
- if (!s)
- throw InvalidStreamException();
- detail::AreaBase const * a (AreaRegistry::instance().lookup(area));
- if (!a)
- throw InvalidAreaException();
- route(s, a, NONE::value, action);
+ unroute(0, 0, NONE::value, action);
}
-prefix_ void senf::log::Target::route(std::string const & stream, unsigned level, action_t action)
+prefix_ senf::log::Target::iterator senf::log::Target::begin()
+ const
{
- detail::StreamBase const * s (StreamRegistry::instance().lookup(stream));
- if (!s)
- throw InvalidStreamException();
- route(s, 0, level, action);
+ return rib_.begin();
}
-prefix_ void senf::log::Target::route(std::string const & stream, std::string const & area,
- unsigned level, action_t action)
+prefix_ senf::log::Target::iterator senf::log::Target::end()
+ const
{
- detail::StreamBase const * s (StreamRegistry::instance().lookup(stream));
- if (!s)
- throw InvalidStreamException();
- detail::AreaBase const * a (AreaRegistry::instance().lookup(area));
- if (!a)
- throw InvalidAreaException();
- route(s, a, level, action);
+ return rib_.end();
}
-////////////////////////////////////////
-// private members
+prefix_ senf::log::Target::RoutingEntry const & senf::log::Target::operator[](size_type i)
+ const
+{
+ return rib_[i];
+}
-prefix_ void senf::log::Target::route(detail::StreamBase const * stream,
- detail::AreaBase const * area, unsigned level,
- action_t action)
+prefix_ senf::log::Target::size_type senf::log::Target::size()
+ const
{
- rib_.push_back(RoutingEntry(stream, area, level, action));
- if (action == ACCEPT)
- updateRoutingCache(stream, area);
+ return rib_.size();
}
-prefix_ void senf::log::Target::unroute(detail::StreamBase const * stream,
- detail::AreaBase const * area, unsigned level,
- action_t action)
+prefix_ bool senf::log::Target::empty()
+ const
{
- rib_.erase(std::remove(rib_.begin(), rib_.end(), RoutingEntry(stream, area, level, action)),
- rib_.end());
- if (action == ACCEPT)
- updateRoutingCache(stream, area);
+ return rib_.empty();
}
///////////////////////////////////////////////////////////////////////////
// senf::log::Target::RoutingEntry
-prefix_ senf::log::Target::RoutingEntry::RoutingEntry(detail::StreamBase const * stream_,
- detail::AreaBase const * area_,
- unsigned level_, action_t action_)
- : stream(stream_), area(area_), level(level_), action(action_)
+prefix_ senf::log::Target::RoutingEntry::RoutingEntry(detail::StreamBase const * stream,
+ detail::AreaBase const * area,
+ unsigned level, action_t action)
+ : stream_(stream), area_(area), level_(level), action_(action)
{}
prefix_ senf::log::Target::RoutingEntry::RoutingEntry()
- : stream(0), area(0), level(0), action(ACCEPT)
+ : stream_(0), area_(0), level_(0), action_(ACCEPT)
{}
prefix_ bool senf::log::Target::RoutingEntry::operator==(RoutingEntry const & other)
+ const
{
return
- stream == other.stream &&
- area == other.area &&
- level == other.level &&
- action == other.action;
+ stream_ == other.stream_ &&
+ area_ == other.area_ &&
+ level_ == other.level_ &&
+ action_ == other.action_;
+}
+
+prefix_ std::string senf::log::Target::RoutingEntry::stream()
+ const
+{
+ return stream_ ? stream_->v_name() : "";
+}
+
+prefix_ std::string senf::log::Target::RoutingEntry::area()
+ const
+{
+ return area_ ? area_->v_name() : "";
+}
+
+prefix_ unsigned senf::log::Target::RoutingEntry::level()
+ const
+{
+ return level_;
+}
+
+prefix_ senf::log::Target::action_t senf::log::Target::RoutingEntry::action()
+ const
+{
+ return action_;
}
///////////////////////////////////////////////////////////////////////////
-// senf::log::TargetRegistry
+// senf::log::detail::TargetRegistry
+
+prefix_ void senf::log::detail::TargetRegistry::routed()
+{
+ fallbackRouting_ = false;
+}
-prefix_ void senf::log::TargetRegistry::registerTarget(Target * target)
+prefix_ bool senf::log::detail::TargetRegistry::fallbackRouting()
{
- targets_.insert(target);
+ return fallbackRouting_;
}
-prefix_ void senf::log::TargetRegistry::unregisterTarget(Target * target)
+prefix_ senf::console::ScopedDirectory<> & senf::log::detail::TargetRegistry::consoleDir()
+{
+ return consoleDir_();
+}
+
+////////////////////////////////////////
+// private members
+
+prefix_ void senf::log::detail::TargetRegistry::unregisterTarget(Target * target)
{
targets_.erase(target);
}