diff OrthancServer/main.cpp @ 1247:32fcc5dc7562

abstraction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Dec 2014 13:54:27 +0100
parents aea9277dee75
children 2ffe07abd9d8
line wrap: on
line diff
--- a/OrthancServer/main.cpp	Mon Dec 08 12:56:30 2014 +0100
+++ b/OrthancServer/main.cpp	Mon Dec 08 13:54:27 2014 +0100
@@ -50,6 +50,7 @@
 #include "OrthancFindRequestHandler.h"
 #include "OrthancMoveRequestHandler.h"
 #include "ServerToolbox.h"
+#include "DatabaseWrapper.h"
 #include "../Plugins/Engine/PluginsManager.h"
 #include "../Plugins/Engine/OrthancPlugins.h"
 
@@ -431,13 +432,29 @@
 static bool StartOrthanc()
 {
   std::string storageDirectoryStr = Configuration::GetGlobalStringParameter("StorageDirectory", "OrthancStorage");
+
+
+  // Open the database
   boost::filesystem::path indexDirectory = Configuration::InterpretStringParameterAsPath(
     Configuration::GetGlobalStringParameter("IndexDirectory", storageDirectoryStr));
 
+  std::auto_ptr<IDatabaseWrapper> database;
+  try
+  {
+    boost::filesystem::create_directories(indexDirectory);
+  }
+  catch (boost::filesystem::filesystem_error)
+  {
+  }
+
+  database.reset(new DatabaseWrapper(indexDirectory.string() + "/index"));
+
+
   // "storage" must be declared BEFORE "ServerContext context", to
   // avoid mess in the invokation order of the destructors.
   std::auto_ptr<IStorageArea>  storage;
-  ServerContext context(indexDirectory);
+
+  ServerContext context(*database);
 
   LOG(WARNING) << "Index directory: " << indexDirectory;