diff OrthancServer/ServerContext.cpp @ 791:381f90e2b69d

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 May 2014 22:44:34 +0200
parents aebf0071020e
children 111a1738e11e
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp	Mon May 05 18:55:10 2014 +0200
+++ b/OrthancServer/ServerContext.cpp	Mon May 05 22:44:34 2014 +0200
@@ -247,12 +247,12 @@
 
 
   StoreStatus ServerContext::Store(std::string& resultPublicId,
-                                   DcmFileFormat& dicomInstance,
+                                   ParsedDicomFile& dicomInstance,
                                    const char* dicomBuffer,
                                    size_t dicomSize)
   {
     DicomMap dicomSummary;
-    FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.getDataset());
+    FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.GetDicom().getDataset());
 
     try
     {
@@ -260,7 +260,7 @@
       resultPublicId = hasher.HashInstance();
 
       Json::Value dicomJson;
-      FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset());
+      FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.GetDicom().getDataset());
       
       StoreStatus status = StoreStatus_Failure;
       if (dicomSize > 0)
@@ -283,10 +283,10 @@
 
 
   StoreStatus ServerContext::Store(std::string& resultPublicId,
-                                   DcmFileFormat& dicomInstance)
+                                   ParsedDicomFile& dicomInstance)
   {
     std::string buffer;
-    if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.getDataset()))
+    if (!FromDcmtkBridge::SaveToMemoryBuffer(buffer, dicomInstance.GetDicom().getDataset()))
     {
       throw OrthancException(ErrorCode_InternalError);
     }
@@ -303,9 +303,24 @@
                                    size_t dicomSize)
   {
     ParsedDicomFile dicom(dicomBuffer, dicomSize);
-    return Store(resultPublicId, dicom.GetDicom(), dicomBuffer, dicomSize);
+    return Store(resultPublicId, dicom, dicomBuffer, dicomSize);
   }
 
+
+  StoreStatus ServerContext::Store(std::string& resultPublicId,
+                                   const std::string& dicomContent)
+  {
+    if (dicomContent.size() == 0)
+    {
+      return Store(resultPublicId, NULL, 0);
+    }
+    else
+    {
+      return Store(resultPublicId, &dicomContent[0], dicomContent.size());
+    }
+  }
+
+
   void ServerContext::SetStoreMD5ForAttachments(bool storeMD5)
   {
     LOG(INFO) << "Storing MD5 for attachments: " << (storeMD5 ? "yes" : "no");