sensors: add method to grab default timeout

Add a central method for grabbing the default timeout for a sensor.
This is required to allow for a configuration to leave out an
unnecessary field.

Change-Id: I29ecd9db67b1eb1e66e60ef49859926cf14a4542
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/sensors/sensor.hpp b/sensors/sensor.hpp
index 6df5aa2..2dbfa30 100644
--- a/sensors/sensor.hpp
+++ b/sensors/sensor.hpp
@@ -11,6 +11,20 @@
 class Sensor
 {
   public:
+    /**
+     * Given a sensor's type, return the default timeout value.
+     * A timeout of 0 means there isn't a timeout for this sensor.
+     * By default a fan sensor isn't checked for a timeout, whereas
+     * any of sensor is meant to be sampled once per second.  By default.
+     *
+     * @param[in] type - the sensor type (e.g. fan)
+     * @return the default timeout for that type (in seconds).
+     */
+    static int64_t getDefaultTimeout(const std::string& type)
+    {
+        return (type == "fan") ? 0 : 2;
+    }
+
     Sensor(const std::string& name, int64_t timeout) :
         _name(name), _timeout(timeout)
     {