Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1615:c40fe92a68e7
Primitives to upgrade the database version in plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 16 Sep 2015 15:18:59 +0200 |
parents | 1ec254a7c645 |
children | 0a2ad4a6858f |
comparison
equal
deleted
inserted
replaced
1614:1c9e99d2bfd2 | 1615:c40fe92a68e7 |
---|---|
163 throw OrthancException(ErrorCode_ParameterOutOfRange); | 163 throw OrthancException(ErrorCode_ParameterOutOfRange); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 | 167 |
168 static OrthancPluginContentType Convert(FileContentType type) | |
169 { | |
170 switch (type) | |
171 { | |
172 case FileContentType_Dicom: | |
173 return OrthancPluginContentType_Dicom; | |
174 | |
175 case FileContentType_DicomAsJson: | |
176 return OrthancPluginContentType_DicomAsJson; | |
177 | |
178 default: | |
179 return OrthancPluginContentType_Unknown; | |
180 } | |
181 } | |
182 | |
183 | |
184 static FileContentType Convert(OrthancPluginContentType type) | |
185 { | |
186 switch (type) | |
187 { | |
188 case OrthancPluginContentType_Dicom: | |
189 return FileContentType_Dicom; | |
190 | |
191 case OrthancPluginContentType_DicomAsJson: | |
192 return FileContentType_DicomAsJson; | |
193 | |
194 default: | |
195 return FileContentType_Unknown; | |
196 } | |
197 } | |
198 | |
168 | 199 |
169 struct OrthancPlugins::PImpl | 200 struct OrthancPlugins::PImpl |
170 { | 201 { |
171 class RestCallback : public boost::noncopyable | 202 class RestCallback : public boost::noncopyable |
172 { | 203 { |
1616 | 1647 |
1617 case _OrthancPluginService_DrawText: | 1648 case _OrthancPluginService_DrawText: |
1618 DrawText(parameters); | 1649 DrawText(parameters); |
1619 return true; | 1650 return true; |
1620 | 1651 |
1652 case _OrthancPluginService_StorageAreaCreate: | |
1653 { | |
1654 const _OrthancPluginStorageAreaCreate& p = | |
1655 *reinterpret_cast<const _OrthancPluginStorageAreaCreate*>(parameters); | |
1656 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea); | |
1657 storage.Create(p.uuid, p.content, p.size, Convert(p.type)); | |
1658 return true; | |
1659 } | |
1660 | |
1661 case _OrthancPluginService_StorageAreaRead: | |
1662 { | |
1663 const _OrthancPluginStorageAreaRead& p = | |
1664 *reinterpret_cast<const _OrthancPluginStorageAreaRead*>(parameters); | |
1665 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea); | |
1666 std::string content; | |
1667 storage.Read(content, p.uuid, Convert(p.type)); | |
1668 CopyToMemoryBuffer(*p.target, content); | |
1669 return true; | |
1670 } | |
1671 | |
1672 case _OrthancPluginService_StorageAreaRemove: | |
1673 { | |
1674 const _OrthancPluginStorageAreaRemove& p = | |
1675 *reinterpret_cast<const _OrthancPluginStorageAreaRemove*>(parameters); | |
1676 IStorageArea& storage = *reinterpret_cast<IStorageArea*>(p.storageArea); | |
1677 storage.Remove(p.uuid, Convert(p.type)); | |
1678 return true; | |
1679 } | |
1680 | |
1621 default: | 1681 default: |
1622 { | 1682 { |
1623 // This service is unknown to the Orthanc plugin engine | 1683 // This service is unknown to the Orthanc plugin engine |
1624 return false; | 1684 return false; |
1625 } | 1685 } |
1649 void Free(void* buffer) const | 1709 void Free(void* buffer) const |
1650 { | 1710 { |
1651 if (buffer != NULL) | 1711 if (buffer != NULL) |
1652 { | 1712 { |
1653 params_.free(buffer); | 1713 params_.free(buffer); |
1654 } | |
1655 } | |
1656 | |
1657 OrthancPluginContentType Convert(FileContentType type) const | |
1658 { | |
1659 switch (type) | |
1660 { | |
1661 case FileContentType_Dicom: | |
1662 return OrthancPluginContentType_Dicom; | |
1663 | |
1664 case FileContentType_DicomAsJson: | |
1665 return OrthancPluginContentType_DicomAsJson; | |
1666 | |
1667 default: | |
1668 return OrthancPluginContentType_Unknown; | |
1669 } | 1714 } |
1670 } | 1715 } |
1671 | 1716 |
1672 public: | 1717 public: |
1673 PluginStorageArea(const _OrthancPluginRegisterStorageArea& params) : params_(params) | 1718 PluginStorageArea(const _OrthancPluginRegisterStorageArea& params) : params_(params) |