# HG changeset patch # User Sebastien Jodogne # Date 1560282678 -7200 # Node ID ad263225187c2a58b04744c4b02ff2b367d623f1 # Parent 541c787e22308968510581c86efc43f44816f5c4 fix for older compilers diff -r 541c787e2230 -r ad263225187c Plugins/Samples/Common/OrthancPluginCppWrapper.h --- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h Tue Jun 11 21:38:34 2019 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h Tue Jun 11 21:51:18 2019 +0200 @@ -1026,33 +1026,39 @@ } - + + // NB: We use a templated class instead of a templated function, because + // default values are only available in functions since C++11 template< RestCallback GetHandler = Internals::NullRestCallback, ChunkedRestCallback PostHandler = Internals::NullChunkedRestCallback, RestCallback DeleteHandler = Internals::NullRestCallback, ChunkedRestCallback PutHandler = Internals::NullChunkedRestCallback > - void RegisterChunkedRestCallback(const std::string& uri) + class ChunkedRestRegistration : public boost::noncopyable { + public: + static void Apply(const std::string& uri) + { #if HAS_ORTHANC_PLUGIN_CHUNKED_HTTP_SERVER == 1 - OrthancPluginRegisterChunkedRestCallback( - GetGlobalContext(), uri.c_str(), - GetHandler == Internals::NullRestCallback ? NULL : Internals::Protect, - PostHandler == Internals::NullChunkedRestCallback ? NULL : Internals::Protect, - DeleteHandler == Internals::NullRestCallback ? NULL : Internals::Protect, - PutHandler == Internals::NullChunkedRestCallback ? NULL : Internals::Protect, - Internals::ChunkedRequestReaderAddChunk, - Internals::ChunkedRequestReaderExecute, - Internals::ChunkedRequestReaderFinalize); + OrthancPluginRegisterChunkedRestCallback( + GetGlobalContext(), uri.c_str(), + GetHandler == Internals::NullRestCallback ? NULL : Internals::Protect, + PostHandler == Internals::NullChunkedRestCallback ? NULL : Internals::Protect, + DeleteHandler == Internals::NullRestCallback ? NULL : Internals::Protect, + PutHandler == Internals::NullChunkedRestCallback ? NULL : Internals::Protect, + Internals::ChunkedRequestReaderAddChunk, + Internals::ChunkedRequestReaderExecute, + Internals::ChunkedRequestReaderFinalize); #else - LogWarning("Performance warning: The plugin was compiled against a pre-1.5.7 version " - "of the Orthanc SDK. Multipart transfers will be entirely stored in RAM."); - - OrthancPluginRegisterRestCallback( - GetGlobalContext(), uri.c_str(), - Internals::Protect< Internals::ChunkedRestCompatibility< - GetHandler, PostHandler, DeleteHandler, PutHandler> >); + LogWarning("Performance warning: The plugin was compiled against a pre-1.5.7 version " + "of the Orthanc SDK. Multipart transfers will be entirely stored in RAM."); + + OrthancPluginRegisterRestCallback( + GetGlobalContext(), uri.c_str(), + Internals::Protect< Internals::ChunkedRestCompatibility< + GetHandler, PostHandler, DeleteHandler, PutHandler> >); #endif - } + } + }; }