Small fixes and tidy-ups spotted by cppcheck.
[dcpomatic.git] / src / lib / update.h
index c86adb8736adad074625f8b7a73dd47ae1eb666e..5bb9e95016de1ed2bace2ec556fd54f9dccfef07 100644 (file)
  *  @brief UpdateChecker class.
  */
 
+#include <curl/curl.h>
 #include <boost/signals2.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition.hpp>
 #include <boost/thread.hpp>
-#include <curl/curl.h>
+
+struct update_checker_test;
 
 /** Class to check for the existance of an update for DCP-o-matic on a remote server */
-class UpdateChecker
+class UpdateChecker : public boost::noncopyable
 {
 public:
        UpdateChecker ();
@@ -49,14 +51,14 @@ public:
                return _state;
        }
        
-       /** @return the version string of the latest stable version (if _state == YES or NO) */
-       std::string stable () {
+       /** @return new stable version, if there is one */
+       boost::optional<std::string> stable () {
                boost::mutex::scoped_lock lm (_data_mutex);
                return _stable;
        }
 
-       /** @return the version string of the latest test version (if _state == YES or NO) */
-       std::string test () {
+       /** @return new test version, if there is one and Config is set to look for it */
+       boost::optional<std::string> test () {
                boost::mutex::scoped_lock lm (_data_mutex);
                return _test;
        }
@@ -73,9 +75,13 @@ public:
 
        static UpdateChecker* instance ();
 
-private:       
+private:
+       friend struct update_checker_test;
+       
        static UpdateChecker* _instance;
 
+       static bool version_less_than (std::string const & a, std::string const & b);
+
        void set_state (State);
        void thread ();
 
@@ -86,8 +92,8 @@ private:
        /** mutex to protect _state, _stable, _test and _emits */
        mutable boost::mutex _data_mutex;
        State _state;
-       std::string _stable;
-       std::string _test;
+       boost::optional<std::string> _stable;
+       boost::optional<std::string> _test;
        int _emits;
 
        boost::thread* _thread;