From: tho Date: Tue, 19 Oct 2010 15:38:59 +0000 (+0000) Subject: Utils/Statistics: added operator[] member to get const & Collector in StatisticsBase X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=0da9e6722316a6ba5cfea039ea5766dd988b77da;p=senf.git Utils/Statistics: added operator[] member to get const & Collector in StatisticsBase git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1737 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/Statistics.cc b/senf/Utils/Statistics.cc index 10f603e..5c24563 100644 --- a/senf/Utils/Statistics.cc +++ b/senf/Utils/Statistics.cc @@ -62,6 +62,15 @@ prefix_ senf::Collector & senf::StatisticsBase::operator[](unsigned rank) return i->second; } +prefix_ senf::Collector const & senf::StatisticsBase::operator[](unsigned rank) + const +{ + Children::const_iterator i (children_.find(rank)); + if (i == children_.end()) + throw InvalidRankException(); + return i->second; +} + prefix_ senf::Collector & senf::StatisticsBase::collect(unsigned rank) { std::pair state ( diff --git a/senf/Utils/Statistics.hh b/senf/Utils/Statistics.hh index 1e2cb4d..4a29c8c 100644 --- a/senf/Utils/Statistics.hh +++ b/senf/Utils/Statistics.hh @@ -172,6 +172,14 @@ namespace senf { collector collects into each combined value. \throws InvalidRankException if \a rank is not a valid registered rank value. */ + Collector const & operator[](unsigned rank) const; + ///< Get child collector + /**< This member will return a const reference to the + collector collecting \a rank values. + \param[in] rank Number of values the requested + collector collects into each combined value. + \throws InvalidRankException if \a rank is not a valid + registered rank value. */ CollectorRange collectors(); ///< List all child collectors /**< \returns iterator range of child collector references */