comparison Plugins/Samples/Common/OrthancPluginCppWrapper.h @ 3397:9019279dbfd7

new plugin c++ wrapper: MultipartRestCallback
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Jun 2019 11:26:34 +0200
parents 2cd0369a156f
children 4e8205871967
comparison
equal deleted inserted replaced
3396:4981405e6c5c 3397:9019279dbfd7
95 # define HAS_ORTHANC_PLUGIN_STREAMING_HTTP_CLIENT 1 95 # define HAS_ORTHANC_PLUGIN_STREAMING_HTTP_CLIENT 1
96 #else 96 #else
97 # define HAS_ORTHANC_PLUGIN_STREAMING_HTTP_CLIENT 0 97 # define HAS_ORTHANC_PLUGIN_STREAMING_HTTP_CLIENT 0
98 #endif 98 #endif
99 99
100 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 5, 7)
101 # define HAS_ORTHANC_PLUGIN_HTTP_MULTIPART_SERVER 1
102 #else
103 # define HAS_ORTHANC_PLUGIN_HTTP_MULTIPART_SERVER 0
104 #endif
105
100 106
101 107
102 namespace OrthancPlugins 108 namespace OrthancPlugins
103 { 109 {
104 typedef void (*RestCallback) (OrthancPluginRestOutput* output, 110 typedef void (*RestCallback) (OrthancPluginRestOutput* output,
363 OrthancImage(OrthancPluginPixelFormat format, 369 OrthancImage(OrthancPluginPixelFormat format,
364 uint32_t width, 370 uint32_t width,
365 uint32_t height, 371 uint32_t height,
366 uint32_t pitch, 372 uint32_t pitch,
367 void* buffer 373 void* buffer
368 ); 374 );
369 375
370 ~OrthancImage() 376 ~OrthancImage()
371 { 377 {
372 Clear(); 378 Clear();
373 } 379 }
566 { 572 {
567 // The "false" instructs Orthanc not to log the detailed 573 // The "false" instructs Orthanc not to log the detailed
568 // error message. This is to avoid duplicating the details, 574 // error message. This is to avoid duplicating the details,
569 // because "OrthancException" already does it on construction. 575 // because "OrthancException" already does it on construction.
570 OrthancPluginSetHttpErrorDetails 576 OrthancPluginSetHttpErrorDetails
571 (GetGlobalContext(), output, e.GetDetails(), false); 577 (GetGlobalContext(), output, e.GetDetails(), false);
572 } 578 }
573 #endif 579 #endif
574 580
575 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); 581 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode());
576 } 582 }
591 bool isThreadSafe) 597 bool isThreadSafe)
592 { 598 {
593 if (isThreadSafe) 599 if (isThreadSafe)
594 { 600 {
595 OrthancPluginRegisterRestCallbackNoLock 601 OrthancPluginRegisterRestCallbackNoLock
596 (GetGlobalContext(), uri.c_str(), Internals::Protect<Callback>); 602 (GetGlobalContext(), uri.c_str(), Internals::Protect<Callback>);
597 } 603 }
598 else 604 else
599 { 605 {
600 OrthancPluginRegisterRestCallback 606 OrthancPluginRegisterRestCallback
601 (GetGlobalContext(), uri.c_str(), Internals::Protect<Callback>); 607 (GetGlobalContext(), uri.c_str(), Internals::Protect<Callback>);
602 } 608 }
603 } 609 }
604 610
605 611
606 #if HAS_ORTHANC_PLUGIN_PEERS == 1 612 #if HAS_ORTHANC_PLUGIN_PEERS == 1
910 916
911 void Execute(HttpHeaders& answerHeaders /* out */, 917 void Execute(HttpHeaders& answerHeaders /* out */,
912 std::string& answerBody /* out */); 918 std::string& answerBody /* out */);
913 }; 919 };
914 #endif 920 #endif
921
922
923
924 #if HAS_ORTHANC_PLUGIN_HTTP_MULTIPART_SERVER == 1
925 class MultipartRestCallback : public boost::noncopyable
926 {
927 public:
928 class IHandler : public boost::noncopyable
929 {
930 public:
931 virtual ~IHandler()
932 {
933 }
934
935 virtual OrthancPluginErrorCode AddPart(const std::string& contentType,
936 const std::map<std::string, std::string>& headers,
937 const void* data,
938 size_t size) = 0;
939
940 virtual OrthancPluginErrorCode Execute(OrthancPluginRestOutput* output) = 0;
941 };
942
943
944 virtual ~MultipartRestCallback()
945 {
946 }
947
948 virtual IHandler* CreateHandler(OrthancPluginHttpMethod method,
949 const std::string& url,
950 const std::string& contentType,
951 const std::vector<std::string>& groups,
952 const std::map<std::string, std::string>& headers) = 0;
953
954 void Register(const std::string& regularExpression);
955 };
956 #endif
915 } 957 }