diff OrthancServer/FromDcmtkBridge.h @ 784:efd0215736d9

start of anonymization refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 May 2014 15:06:31 +0200
parents 2d0a347e8cfc
children 7ebe4bf87196
line wrap: on
line diff
--- a/OrthancServer/FromDcmtkBridge.h	Fri May 02 12:59:05 2014 +0200
+++ b/OrthancServer/FromDcmtkBridge.h	Fri May 02 15:06:31 2014 +0200
@@ -58,66 +58,6 @@
     DicomReplaceMode_IgnoreIfAbsent
   };
 
-  class ParsedDicomFile : public IDynamicObject
-  {
-  private:
-    std::auto_ptr<DcmFileFormat> file_;
-
-    ParsedDicomFile(DcmFileFormat& other) :
-      file_(dynamic_cast<DcmFileFormat*>(other.clone()))
-    {
-    }
-
-    void Setup(const char* content,
-               size_t size);
-
-  public:
-    ParsedDicomFile(const char* content,
-                    size_t size)
-    {
-      Setup(content, size);
-    }
-
-    ParsedDicomFile(const std::string& content)
-    {
-      if (content.size() == 0)
-        Setup(NULL, 0);
-      else
-        Setup(&content[0], content.size());
-    }
-
-    DcmFileFormat& GetDicom()
-    {
-      return *file_;
-    }
-
-    ParsedDicomFile* Clone()
-    {
-      return new ParsedDicomFile(*file_);
-    }
-
-    void SendPathValue(RestApiOutput& output,
-                       const UriComponents& uri);
-
-    void Answer(RestApiOutput& output);
-
-    void Remove(const DicomTag& tag);
-
-    void Insert(const DicomTag& tag,
-                const std::string& value);
-
-    void Replace(const DicomTag& tag,
-                 const std::string& value,
-                 DicomReplaceMode mode);
-
-    void RemovePrivateTags();
-
-    bool GetTagValue(std::string& value,
-                     const DicomTag& tag);
-
-    DicomInstanceHasher GetHasher();
-  };
-
   class FromDcmtkBridge
   {
   public:
@@ -184,4 +124,74 @@
     static bool SaveToMemoryBuffer(std::string& buffer,
                                    DcmDataset* dataSet);
   };
+
+  class ParsedDicomFile : public IDynamicObject
+  {
+  private:
+    std::auto_ptr<DcmFileFormat> file_;
+
+    ParsedDicomFile(DcmFileFormat& other) :
+      file_(dynamic_cast<DcmFileFormat*>(other.clone()))
+    {
+    }
+
+    void Setup(const char* content,
+               size_t size);
+
+  public:
+    ParsedDicomFile();  // Create a minimal DICOM instance
+
+    ParsedDicomFile(const char* content,
+                    size_t size)
+    {
+      Setup(content, size);
+    }
+
+    ParsedDicomFile(const std::string& content)
+    {
+      if (content.size() == 0)
+        Setup(NULL, 0);
+      else
+        Setup(&content[0], content.size());
+    }
+
+    DcmFileFormat& GetDicom()
+    {
+      return *file_;
+    }
+
+    ParsedDicomFile* Clone()
+    {
+      return new ParsedDicomFile(*file_);
+    }
+
+    void SendPathValue(RestApiOutput& output,
+                       const UriComponents& uri);
+
+    void Answer(RestApiOutput& output);
+
+    void Remove(const DicomTag& tag);
+
+    void Insert(const DicomTag& tag,
+                const std::string& value);
+
+    void Replace(const DicomTag& tag,
+                 const std::string& value,
+                 DicomReplaceMode mode = DicomReplaceMode_InsertIfAbsent);
+
+    void RemovePrivateTags();
+
+    bool GetTagValue(std::string& value,
+                     const DicomTag& tag);
+
+    DicomInstanceHasher GetHasher();
+
+    void SaveToMemoryBuffer(std::string& buffer)
+    {
+      FromDcmtkBridge::SaveToMemoryBuffer(buffer, file_->getDataset());
+    }
+
+    void SaveToFile(const std::string& path);
+  };
+
 }