]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3793] Changes after review:
authorTomek Mrugalski <tomasz@isc.org>
Fri, 15 May 2015 12:36:28 +0000 (14:36 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 15 May 2015 12:36:28 +0000 (14:36 +0200)
 - Added rationale for ptimeToText, durationToText
 - Added missing headers
 - Removed the default values in addValue()
 - StatsDuration is now passed by reference

src/lib/stats/observation.cc
src/lib/stats/observation.h
src/lib/util/boost_time_utils.cc
src/lib/util/boost_time_utils.h

index bfd88b320f5868cdabece4328bac879ee2a69a7f..6b31a5c84ec8f9243a87dacff1218b83c71cf0c8 100644 (file)
@@ -36,7 +36,7 @@ Observation::Observation(const std::string& name, const double value)
     setValue(value);
 }
 
-Observation::Observation(const std::string& name, const StatsDuration value)
+Observation::Observation(const std::string& name, const StatsDuration& value)
     :name_(name), type_(STAT_DURATION) {
     setValue(value);
 }
index 9dc7e09d4519e2d8518cbe26b30d569ceb10054d..0ba3b1892b86dcfe70c73b49a6f7eb4b7f7773fd 100644 (file)
@@ -110,7 +110,7 @@ class Observation {
     ///
     /// @param name observation name
     /// @param value duration observed.
-    Observation(const std::string& name, const StatsDuration value);
+    Observation(const std::string& name, const StatsDuration& value);
 
     /// @brief Constructor for string observations
     ///
@@ -146,25 +146,25 @@ class Observation {
     ///
     /// @param value integer value observed
     /// @throw InvalidStatType if statistic is not integer
-    void addValue(const uint64_t value = 1);
+    void addValue(const uint64_t value);
 
     /// @brief Records incremental floating point observation
     ///
     /// @param value floating point value observed
     /// @throw InvalidStatType if statistic is not fp
-    void addValue(const double value = 1.0f);
+    void addValue(const double value);
 
     /// @brief Records incremental duration observation
     ///
     /// @param value duration value observed
     /// @throw InvalidStatType if statistic is not time duration
-    void addValue(const StatsDuration& value = StatsDuration(0,0,1,0));
+    void addValue(const StatsDuration& value);
 
     /// @brief Records incremental string observation.
     ///
     /// @param value string value observed
     /// @throw InvalidStatType if statistic is not a string
-    void addValue(const std::string& value = "");
+    void addValue(const std::string& value);
 
     /// @brief Resets statistic.
     ///
index feefc5c4586363f170f151036a7d2ec95661b181..8fca836e4fbd08d4111c6e38ab88373f14944918 100644 (file)
@@ -13,6 +13,8 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <util/boost_time_utils.h>
+#include <sstream>
+#include <iomanip>
 
 std::string
 isc::util::ptimeToText(boost::posix_time::ptime t) {
index f8e73155858edf2e375d5e1189d0288697303ce5..df6be8cc6eebccd8510caa9f5ad2282f45978236 100644 (file)
 #define KEA_BOOST_TIME_UTILS_H
 
 #include <boost/date_time/posix_time/posix_time.hpp>
+#include <string>
 
 namespace isc {
 namespace util {
 
 /// @brief Converts ptime structure to text
+///
+/// This is Kea implementation for converting ptime to strings.
+/// It's a functional equivalent of boost::posix_time::to_simple_string. We do
+/// not use it, though, because it would introduce unclear dependency on
+/// boost_time_date library. First, we try to avoid depending on boost libraries
+/// (we tend to use only the headers). Second, this dependency is system
+/// specific, i.e. it is required on Ubuntu and FreeBSD, but doesn't seem to
+/// be needed on OS X. Since the functionality needed is minor, we decided to
+/// reimplement it on our own, rather than introduce extra dependencies.
+/// This explanation also applies to @ref durationToText.
+///
 /// @return a string representing time
 std::string ptimeToText(boost::posix_time::ptime t);
 
 /// @brief Converts StatsDuration to text
+///
+/// This is Kea equivalent of boost::posix_time::to_simple_string(time_duration).
+/// See @ref ptimeToText for explanation why we chose our own implementation.
+///
 /// @return a string representing time
 std::string durationToText(boost::posix_time::time_duration dur);