Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1145:0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 11 Sep 2014 13:06:16 +0200 |
parents | d9c27f9f1a51 |
children | 1ea4094d077c |
comparison
equal
deleted
inserted
replaced
1144:fef79a477e09 | 1145:0479d02c6778 |
---|---|
36 #include "../../Core/OrthancException.h" | 36 #include "../../Core/OrthancException.h" |
37 #include "../../Core/Toolbox.h" | 37 #include "../../Core/Toolbox.h" |
38 #include "../../Core/HttpServer/HttpOutput.h" | 38 #include "../../Core/HttpServer/HttpOutput.h" |
39 #include "../../Core/ImageFormats/PngWriter.h" | 39 #include "../../Core/ImageFormats/PngWriter.h" |
40 #include "../../OrthancServer/ServerToolbox.h" | 40 #include "../../OrthancServer/ServerToolbox.h" |
41 #include "../../OrthancServer/OrthancInitialization.h" | |
41 | 42 |
42 #include <boost/regex.hpp> | 43 #include <boost/regex.hpp> |
43 #include <glog/logging.h> | 44 #include <glog/logging.h> |
44 | 45 |
45 namespace Orthanc | 46 namespace Orthanc |
571 | 572 |
572 | 573 |
573 void OrthancPlugins::LookupResource(_OrthancPluginService service, | 574 void OrthancPlugins::LookupResource(_OrthancPluginService service, |
574 const void* parameters) | 575 const void* parameters) |
575 { | 576 { |
576 const _OrthancPluginLookupResource& p = | 577 const _OrthancPluginRetrieveDynamicString& p = |
577 *reinterpret_cast<const _OrthancPluginLookupResource*>(parameters); | 578 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters); |
578 | 579 |
579 /** | 580 /** |
580 * The enumeration below only uses the tags that are indexed in | 581 * The enumeration below only uses the tags that are indexed in |
581 * the Orthanc database. It reflects the | 582 * the Orthanc database. It reflects the |
582 * "CandidateResources::ApplyFilter()" method of the | 583 * "CandidateResources::ApplyFilter()" method of the |
615 default: | 616 default: |
616 throw OrthancException(ErrorCode_InternalError); | 617 throw OrthancException(ErrorCode_InternalError); |
617 } | 618 } |
618 | 619 |
619 std::list<std::string> result; | 620 std::list<std::string> result; |
620 pimpl_->context_.GetIndex().LookupTagValue(result, tag, p.identifier, level); | 621 pimpl_->context_.GetIndex().LookupTagValue(result, tag, p.argument, level); |
621 | 622 |
622 if (result.size() == 1) | 623 if (result.size() == 1) |
623 { | 624 { |
624 *p.result = CopyString(result.front()); | 625 *p.result = CopyString(result.front()); |
625 } | 626 } |
741 } | 742 } |
742 } | 743 } |
743 | 744 |
744 | 745 |
745 bool OrthancPlugins::InvokeService(_OrthancPluginService service, | 746 bool OrthancPlugins::InvokeService(_OrthancPluginService service, |
746 const void* parameters) | 747 const void* parameters) |
747 { | 748 { |
748 switch (service) | 749 switch (service) |
749 { | 750 { |
751 case _OrthancPluginService_GetOrthancPath: | |
752 { | |
753 std::string s = Toolbox::GetPathToExecutable(); | |
754 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s); | |
755 return true; | |
756 } | |
757 | |
758 case _OrthancPluginService_GetOrthancDirectory: | |
759 { | |
760 std::string s = Toolbox::GetDirectoryOfExecutable(); | |
761 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = CopyString(s); | |
762 return true; | |
763 } | |
764 | |
765 case _OrthancPluginService_GetConfigurationPath: | |
766 { | |
767 *reinterpret_cast<const _OrthancPluginRetrieveDynamicString*>(parameters)->result = | |
768 CopyString(Configuration::GetConfigurationAbsolutePath()); | |
769 return true; | |
770 } | |
771 | |
750 case _OrthancPluginService_RegisterRestCallback: | 772 case _OrthancPluginService_RegisterRestCallback: |
751 RegisterRestCallback(parameters); | 773 RegisterRestCallback(parameters); |
752 return true; | 774 return true; |
753 | 775 |
754 case _OrthancPluginService_RegisterOnStoredInstanceCallback: | 776 case _OrthancPluginService_RegisterOnStoredInstanceCallback: |