changeset 3879:a18b34dec94a transcoding

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 May 2020 19:17:07 +0200
parents 661c931f22ad
children cdd0cb5ec4e4
files Core/DicomNetworking/DicomStoreUserConnection.cpp Core/DicomNetworking/DicomStoreUserConnection.h
diffstat 2 files changed, 32 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomStoreUserConnection.cpp	Mon May 04 17:02:50 2020 +0200
+++ b/Core/DicomNetworking/DicomStoreUserConnection.cpp	Mon May 04 19:17:07 2020 +0200
@@ -153,13 +153,13 @@
   void DicomStoreUserConnection::RegisterStorageClass(const std::string& sopClassUid,
                                                       DicomTransferSyntax syntax)
   {
-    StorageClasses::iterator found = storageClasses_.find(sopClassUid);
+    RegisteredClasses::iterator found = registeredClasses_.find(sopClassUid);
 
-    if (found == storageClasses_.end())
+    if (found == registeredClasses_.end())
     {
       std::set<DicomTransferSyntax> ts;
       ts.insert(syntax);
-      storageClasses_[sopClassUid] = ts;
+      registeredClasses_[sopClassUid] = ts;
     }
     else
     {
@@ -217,19 +217,20 @@
     }
     
     association_->ClearPresentationContexts();
-    RegisterStorageClass(sopClassUid, transferSyntax);
+    RegisterStorageClass(sopClassUid, transferSyntax);  // (*)
 
-      
+    
     /**
      * Step 2: Propose at least the mandatory SOP class.
      **/
 
     {
-      StorageClasses::const_iterator mandatory = storageClasses_.find(sopClassUid);
+      RegisteredClasses::const_iterator mandatory = registeredClasses_.find(sopClassUid);
 
-      if (mandatory == storageClasses_.end() ||
+      if (mandatory == registeredClasses_.end() ||
           mandatory->second.find(transferSyntax) == mandatory->second.end())
       {
+        // Should never fail because of (*)
         throw OrthancException(ErrorCode_InternalError);
       }
 
@@ -248,8 +249,8 @@
      * registered through the "RegisterStorageClass()" method.
      **/
       
-    for (StorageClasses::const_iterator it = storageClasses_.begin();
-         it != storageClasses_.end(); ++it)
+    for (RegisteredClasses::const_iterator it = registeredClasses_.begin();
+         it != registeredClasses_.end(); ++it)
     {
       if (it->first != sopClassUid)
       {
@@ -277,7 +278,7 @@
         std::string c(dcmShortSCUStorageSOPClassUIDs[i]);
           
         if (c != sopClassUid &&
-            storageClasses_.find(c) == storageClasses_.end())
+            registeredClasses_.find(c) == registeredClasses_.end())
         {
           ProposeStorageClass(c, ts);
         }
@@ -295,11 +296,11 @@
   }
 
 
-  void DicomStoreUserConnection::Store(std::string& sopClassUid,
-                                       std::string& sopInstanceUid,
-                                       DcmDataset& dataset,
-                                       const std::string& moveOriginatorAET,
-                                       uint16_t moveOriginatorID)
+  void DicomStoreUserConnection::StoreInternal(std::string& sopClassUid,
+                                               std::string& sopInstanceUid,
+                                               DcmDataset& dataset,
+                                               const std::string& moveOriginatorAET,
+                                               uint16_t moveOriginatorID)
   {
     DicomTransferSyntax transferSyntax;
     LookupParameters(sopClassUid, sopInstanceUid, transferSyntax, dataset);
@@ -372,22 +373,6 @@
 
   void DicomStoreUserConnection::Store(std::string& sopClassUid,
                                        std::string& sopInstanceUid,
-                                       ParsedDicomFile& parsed,
-                                       const std::string& moveOriginatorAET,
-                                       uint16_t moveOriginatorID)
-  {
-    if (parsed.GetDcmtkObject().getDataset() == NULL)
-    {
-      throw OrthancException(ErrorCode_InternalError);
-    }
-    
-    Store(sopClassUid, sopInstanceUid, *parsed.GetDcmtkObject().getDataset(),
-          moveOriginatorAET, moveOriginatorID);
-  }
-
-
-  void DicomStoreUserConnection::Store(std::string& sopClassUid,
-                                       std::string& sopInstanceUid,
                                        const void* buffer,
                                        size_t size,
                                        const std::string& moveOriginatorAET,
@@ -402,7 +387,7 @@
       throw OrthancException(ErrorCode_InternalError);
     }
     
-    Store(sopClassUid, sopInstanceUid, *dicom->getDataset(),
-          moveOriginatorAET, moveOriginatorID);
+    StoreInternal(sopClassUid, sopInstanceUid, *dicom->getDataset(),
+                  moveOriginatorAET, moveOriginatorID);
   }
 }
--- a/Core/DicomNetworking/DicomStoreUserConnection.h	Mon May 04 17:02:50 2020 +0200
+++ b/Core/DicomNetworking/DicomStoreUserConnection.h	Mon May 04 19:17:07 2020 +0200
@@ -64,16 +64,15 @@
   **/
 
   class DicomAssociation;  // Forward declaration for PImpl design pattern
-  class ParsedDicomFile;
 
   class DicomStoreUserConnection : public boost::noncopyable
   {
   private:
-    typedef std::map<std::string, std::set<DicomTransferSyntax> > StorageClasses;
+    typedef std::map<std::string, std::set<DicomTransferSyntax> > RegisteredClasses;
     
     DicomAssociationParameters           parameters_;
     boost::shared_ptr<DicomAssociation>  association_;  // "shared_ptr" is for PImpl
-    StorageClasses                       storageClasses_;
+    RegisteredClasses                    registeredClasses_;
     bool                                 proposeCommonClasses_;
     bool                                 proposeUncompressedSyntaxes_;
     bool                                 proposeRetiredBigEndian_;
@@ -82,6 +81,17 @@
     bool ProposeStorageClass(const std::string& sopClassUid,
                              const std::set<DicomTransferSyntax>& syntaxes);
 
+    void LookupParameters(std::string& sopClassUid,
+                          std::string& sopInstanceUid,
+                          DicomTransferSyntax& transferSyntax,
+                          DcmDataset& dataset);
+
+    void StoreInternal(std::string& sopClassUid,
+                       std::string& sopInstanceUid,
+                       DcmDataset& dataset,
+                       const std::string& moveOriginatorAET,
+                       uint16_t moveOriginatorID);
+
   public:
     DicomStoreUserConnection(const DicomAssociationParameters& params);
     
@@ -128,32 +138,12 @@
     bool LookupPresentationContext(uint8_t& presentationContextId,
                                    const std::string& sopClassUid,
                                    DicomTransferSyntax transferSyntax);
-        
+    
     // TODO => to private
     bool NegotiatePresentationContext(uint8_t& presentationContextId,
                                       const std::string& sopClassUid,
                                       DicomTransferSyntax transferSyntax);
 
-    // TODO => to private
-    void LookupParameters(std::string& sopClassUid,
-                          std::string& sopInstanceUid,
-                          DicomTransferSyntax& transferSyntax,
-                          DcmDataset& dataset);
-
-  private:
-    void Store(std::string& sopClassUid,
-               std::string& sopInstanceUid,
-               DcmDataset& dataset,
-               const std::string& moveOriginatorAET,
-               uint16_t moveOriginatorID);
-
-    void Store(std::string& sopClassUid,
-               std::string& sopInstanceUid,
-               ParsedDicomFile& parsed,
-               const std::string& moveOriginatorAET,
-               uint16_t moveOriginatorID);
-
-  public:
     void Store(std::string& sopClassUid,
                std::string& sopInstanceUid,
                const void* buffer,