Utils/Statistics: added operator[] member to get const & Collector in StatisticsBase
tho [Tue, 19 Oct 2010 15:38:59 +0000 (15:38 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1737 270642c3-0616-0410-b53a-bc976706d245

senf/Utils/Statistics.cc
senf/Utils/Statistics.hh

index 10f603e..5c24563 100644 (file)
@@ -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<Children::iterator, bool> state (
index 1e2cb4d..4a29c8c 100644 (file)
@@ -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 */