Mercurial > hg > orthanc
changeset 1397:704de8c30ff5
modularization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 11:50:58 +0200 |
parents | ac4efabeb80c |
children | aa9b8fa97576 |
files | Core/FileStorage/FilesystemStorage.cpp Core/ImageFormats/ImageAccessor.cpp Core/Toolbox.cpp Core/Toolbox.h Plugins/Engine/SharedLibrary.h Resources/CMake/BoostConfiguration.cmake Resources/CMake/GoogleLogConfiguration.cmake UnitTestsSources/UnitTestsMain.cpp |
diffstat | 8 files changed, 65 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/FileStorage/FilesystemStorage.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/FileStorage/FilesystemStorage.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -41,7 +41,10 @@ #include "../Uuid.h" #include <boost/filesystem/fstream.hpp> + +#if HAVE_GOOGLE_LOG == 1 #include <glog/logging.h> +#endif static std::string ToString(const boost::filesystem::path& p) { @@ -82,7 +85,7 @@ //root_ = boost::filesystem::absolute(root).string(); root_ = root; - Toolbox::CreateDirectory(root); + Toolbox::MakeDirectory(root); } void FilesystemStorage::Create(const std::string& uuid, @@ -212,7 +215,10 @@ void FilesystemStorage::Remove(const std::string& uuid, FileContentType /*type*/) { +#if HAVE_GOOGLE_LOG == 1 LOG(INFO) << "Deleting file " << uuid; +#endif + namespace fs = boost::filesystem; fs::path p = GetPath(uuid);
--- a/Core/ImageFormats/ImageAccessor.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/ImageFormats/ImageAccessor.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -38,8 +38,12 @@ #include <stdint.h> #include <cassert> +#include <boost/lexical_cast.hpp> + +#if HAVE_GOOGLE_LOG == 1 #include <glog/logging.h> -#include <boost/lexical_cast.hpp> +#endif + namespace Orthanc { @@ -104,7 +108,10 @@ { if (readOnly_) { +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "Trying to write on a read-only image"; +#endif + throw OrthancException(ErrorCode_ReadOnly); } @@ -129,7 +136,10 @@ { if (readOnly_) { +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "Trying to write on a read-only image"; +#endif + throw OrthancException(ErrorCode_ReadOnly); }
--- a/Core/Toolbox.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/Toolbox.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -35,16 +35,27 @@ #include "OrthancException.h" +#include <string> #include <stdint.h> #include <string.h> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> -#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/uuid/sha1.hpp> +#include <boost/lexical_cast.hpp> #include <algorithm> #include <ctype.h> + +#if BOOST_HAS_DATE_TIME == 1 +#include <boost/date_time/posix_time/posix_time.hpp> +#endif + +#if BOOST_HAS_REGEX == 1 #include <boost/regex.hpp> +#endif + +#if HAVE_GOOGLE_LOG == 1 #include <glog/logging.h> +#endif #if defined(_WIN32) #include <windows.h> @@ -699,11 +710,15 @@ return true; } + +#if BOOST_HAS_DATE_TIME == 1 std::string Toolbox::GetNowIsoString() { boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); return boost::posix_time::to_iso_string(now); } +#endif + std::string Toolbox::StripSpaces(const std::string& source) { @@ -805,6 +820,7 @@ } +#if BOOST_HAS_REGEX == 1 std::string Toolbox::WildcardToRegularExpression(const std::string& source) { // TODO - Speed up this with a regular expression @@ -832,6 +848,7 @@ return result; } +#endif @@ -860,6 +877,7 @@ } +#if BOOST_HAS_REGEX == 1 void Toolbox::DecodeDataUriScheme(std::string& mime, std::string& content, const std::string& source) @@ -878,9 +896,10 @@ throw OrthancException(ErrorCode_BadFileFormat); } } +#endif - void Toolbox::CreateDirectory(const std::string& path) + void Toolbox::MakeDirectory(const std::string& path) { if (boost::filesystem::exists(path)) { @@ -1054,7 +1073,10 @@ if (pid == -1) { // Error in fork() +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "Cannot fork a child process"; +#endif + throw OrthancException(ErrorCode_SystemCommand); } else if (pid == 0) @@ -1074,7 +1096,10 @@ if (status != 0) { +#if HAVE_GOOGLE_LOG == 1 LOG(ERROR) << "System command failed with status code " << status; +#endif + throw OrthancException(ErrorCode_SystemCommand); } }
--- a/Core/Toolbox.h Mon Jun 01 11:15:55 2015 +0200 +++ b/Core/Toolbox.h Mon Jun 01 11:50:58 2015 +0200 @@ -122,24 +122,30 @@ std::string StripSpaces(const std::string& source); +#if BOOST_HAS_DATE_TIME == 1 std::string GetNowIsoString(); +#endif // In-place percent-decoding for URL void UrlDecode(std::string& s); Endianness DetectEndianness(); +#if BOOST_HAS_REGEX == 1 std::string WildcardToRegularExpression(const std::string& s); +#endif void TokenizeString(std::vector<std::string>& result, const std::string& source, char separator); +#if BOOST_HAS_REGEX == 1 void DecodeDataUriScheme(std::string& mime, std::string& content, const std::string& source); +#endif - void CreateDirectory(const std::string& path); + void MakeDirectory(const std::string& path); bool IsExistingFile(const std::string& path);
--- a/Plugins/Engine/SharedLibrary.h Mon Jun 01 11:15:55 2015 +0200 +++ b/Plugins/Engine/SharedLibrary.h Mon Jun 01 11:50:58 2015 +0200 @@ -36,6 +36,10 @@ #include <boost/noncopyable.hpp> +#if defined(_WIN32) +#include <windows.h> +#endif + namespace Orthanc { class SharedLibrary : boost::noncopyable
--- a/Resources/CMake/BoostConfiguration.cmake Mon Jun 01 11:15:55 2015 +0200 +++ b/Resources/CMake/BoostConfiguration.cmake Mon Jun 01 11:50:58 2015 +0200 @@ -152,3 +152,9 @@ -DBOOST_HAS_LOCALE=1 ) endif() + + +add_definitions( + -DBOOST_HAS_DATE_TIME=1 + -DBOOST_HAS_REGEX=1 + )
--- a/Resources/CMake/GoogleLogConfiguration.cmake Mon Jun 01 11:15:55 2015 +0200 +++ b/Resources/CMake/GoogleLogConfiguration.cmake Mon Jun 01 11:50:58 2015 +0200 @@ -174,3 +174,5 @@ else() add_definitions(-DHAVE_SECURE_STRING_EXTENSIONS=0) endif() + +add_definitions(-DHAVE_GOOGLE_LOG=1)
--- a/UnitTestsSources/UnitTestsMain.cpp Mon Jun 01 11:15:55 2015 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Mon Jun 01 11:50:58 2015 +0200 @@ -802,7 +802,7 @@ google::InitGoogleLogging("Orthanc"); - Toolbox::CreateDirectory("UnitTestsResults"); + Toolbox::MakeDirectory("UnitTestsResults"); OrthancInitialize(); ::testing::InitGoogleTest(&argc, argv);