changeset 1239:92c6b3b57699

cleaning
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Dec 2014 16:22:18 +0100
parents 6c07108ff1e2
children 62c35e4b67db
files OrthancServer/DatabaseWrapper.cpp OrthancServer/DatabaseWrapper.h OrthancServer/ServerIndex.cpp UnitTestsSources/ServerIndexTests.cpp
diffstat 4 files changed, 19 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Fri Dec 05 16:14:57 2014 +0100
+++ b/OrthancServer/DatabaseWrapper.cpp	Fri Dec 05 16:22:18 2014 +0100
@@ -213,20 +213,6 @@
     }
   }
 
-  std::string DatabaseWrapper::GetGlobalProperty(GlobalProperty property,
-                                                 const std::string& defaultValue)
-  {
-    std::string s;
-    if (LookupGlobalProperty(s, property))
-    {
-      return s;
-    }
-    else
-    {
-      return defaultValue;
-    }
-  }
-
   int64_t DatabaseWrapper::CreateResource(const std::string& publicId,
                                           ResourceType type)
   {
@@ -874,7 +860,12 @@
     }
 
     // Check the version of the database
-    std::string version = GetGlobalProperty(GlobalProperty_DatabaseSchemaVersion, "Unknown");
+    std::string version;
+    if (!LookupGlobalProperty(version, GlobalProperty_DatabaseSchemaVersion))
+    {
+      version = "Unknown";
+    }
+
     bool ok = false;
     try
     {
--- a/OrthancServer/DatabaseWrapper.h	Fri Dec 05 16:14:57 2014 +0100
+++ b/OrthancServer/DatabaseWrapper.h	Fri Dec 05 16:22:18 2014 +0100
@@ -79,9 +79,6 @@
     bool LookupGlobalProperty(std::string& target,
                               GlobalProperty property);
 
-    std::string GetGlobalProperty(GlobalProperty property,
-                                  const std::string& defaultValue);
-
     int64_t CreateResource(const std::string& publicId,
                            ResourceType type);
 
--- a/OrthancServer/ServerIndex.cpp	Fri Dec 05 16:14:57 2014 +0100
+++ b/OrthancServer/ServerIndex.cpp	Fri Dec 05 16:22:18 2014 +0100
@@ -345,9 +345,10 @@
     try
     {
       boost::mutex::scoped_lock lock(that->mutex_);
-      std::string sleepString = that->db_->GetGlobalProperty(GlobalProperty_FlushSleep, "");
+      std::string sleepString;
 
-      if (Toolbox::IsInteger(sleepString))
+      if (that->db_->LookupGlobalProperty(sleepString, GlobalProperty_FlushSleep) &&
+          Toolbox::IsInteger(sleepString))
       {
         sleep = boost::lexical_cast<unsigned int>(sleepString);
       }
@@ -1917,7 +1918,16 @@
                                              const std::string& defaultValue)
   {
     boost::mutex::scoped_lock lock(mutex_);
-    return db_->GetGlobalProperty(property, defaultValue);
+
+    std::string value;
+    if (db_->LookupGlobalProperty(value, property))
+    {
+      return value;
+    }
+    else
+    {
+      return defaultValue;
+    }
   }
 
 }
--- a/UnitTestsSources/ServerIndexTests.cpp	Fri Dec 05 16:14:57 2014 +0100
+++ b/UnitTestsSources/ServerIndexTests.cpp	Fri Dec 05 16:22:18 2014 +0100
@@ -277,8 +277,6 @@
   ASSERT_TRUE(index_->LookupGlobalProperty(s, GlobalProperty_FlushSleep));
   ASSERT_FALSE(index_->LookupGlobalProperty(s, static_cast<GlobalProperty>(42)));
   ASSERT_EQ("World", s);
-  ASSERT_EQ("World", index_->GetGlobalProperty(GlobalProperty_FlushSleep, ""));
-  ASSERT_EQ("None", index_->GetGlobalProperty(static_cast<GlobalProperty>(42), "None"));
 
   FileInfo att;
   ASSERT_TRUE(index_->LookupAttachment(att, a[4], FileContentType_DicomAsJson));