]> Creatis software - gdcm.git/blobdiff - Testing/TestMakeDicomDir.cxx
Fix mistypings
[gdcm.git] / Testing / TestMakeDicomDir.cxx
index 3d6b1bc325decba7eccaf9b5f8ba5bdec73b9ce5..388c3b5390b8227ef94805d2dc65032f149b5d96 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestMakeDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/21 04:51:26 $
-  Version:   $Revision: 1.5 $
+  Date:      $Date: 2008/09/15 15:49:21 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmDicomDir.h"
 #include "gdcmDicomDirPatient.h"
 #include "gdcmDirList.h"
+#include "gdcmCommandManager.h"
 #include "gdcmDebug.h"
 
 // ---
-void StartMethod(void *startMethod) 
+class CommandStart : public GDCM_NAME_SPACE::Command
 {
-  (void)startMethod;
-   std::cout<<"Start parsing"<<std::endl;
-}
+   gdcmTypeMacro(CommandStart);
+   gdcmNewMacro(CommandStart);
+
+public :
+   virtual void Execute()
+   {
+      std::cerr << "Start parsing" << std::endl;
+   }
+
+protected :
+   CommandStart() {}
+};
+
+class CommandEnd : public GDCM_NAME_SPACE::Command
+{
+   gdcmTypeMacro(CommandEnd);
+   gdcmNewMacro(CommandEnd);
+
+public :
+   virtual void Execute()
+   {
+      std::cerr << "End parsing" << std::endl;
+   }
+
+protected :
+   CommandEnd() {}
+};
+
+class CommandProgress : public GDCM_NAME_SPACE::Command
+{
+   gdcmTypeMacro(CommandProgress);
+   gdcmNewMacro(CommandProgress);
+
+public :
+   virtual void Execute()
+   {
+      GDCM_NAME_SPACE::DicomDir *dd=dynamic_cast<GDCM_NAME_SPACE::DicomDir *>(GetObject());
+
+      if(dd)
+         std::cerr << "Progress parsing (" << dd->GetProgress() << ")" << std::endl;
+      else
+         std::cerr << "Progress parsing (NULL)" << std::endl;
+   }
+
+protected :
+   CommandProgress() {}
+};
 
 void EndMethod(void *endMethod) 
 {
@@ -40,14 +85,14 @@ void EndMethod(void *endMethod)
   *            (or GDCM_DATA_ROOT by default)
   *          - Orders the gdcm-readable found Files
   *             according their Patient/Study/Serie/Image characteristics
-  *          - Makes the gdcm::DicomDir. 
+  *          - Makes the GDCM_NAME_SPACE::DicomDir. 
   *          - Writes a file named "NewDICOMDIR".
   *          - Reads "NewDICOMDIR" file.
   */  
 
 int TestMakeDicomDir(int argc, char *argv[])
 {
-   //gdcm::Debug::DebugOn();
+   //GDCM_NAME_SPACE::Debug::DebugOn();
    std::string dirName;   
 
    if (argc > 1)
@@ -59,35 +104,43 @@ int TestMakeDicomDir(int argc, char *argv[])
       dirName = GDCM_DATA_ROOT;
    }
  
-   gdcm::DicomDir *dcmdir;
+   GDCM_NAME_SPACE::DicomDir *dcmdir;
 
    // new style (user is allowed no to load Sequences an/or Shadow Groups)
-   dcmdir = new gdcm::DicomDir( );
+   dcmdir = GDCM_NAME_SPACE::DicomDir::New( );
  
-   // dcmdir->SetLoadMode(NO_SEQ | NO_SHADOW);
+   GDCM_NAME_SPACE::Command *cmd;
+   cmd = CommandStart::New();
+   GDCM_NAME_SPACE::CommandManager::SetCommand(dcmdir,GDCM_NAME_SPACE::CMD_STARTPROGRESS,cmd);
+   cmd->Delete();
+   cmd = CommandProgress::New();
+   GDCM_NAME_SPACE::CommandManager::SetCommand(dcmdir,GDCM_NAME_SPACE::CMD_PROGRESS,cmd);
+   cmd->Delete();
+   cmd = CommandEnd::New();
+   GDCM_NAME_SPACE::CommandManager::SetCommand(dcmdir,GDCM_NAME_SPACE::CMD_ENDPROGRESS,cmd);
+   cmd->Delete();
+
+   // dcmdir->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ | GDCM_NAME_SPACE::LD_NOSHADOW);
    // some images have a wrong length for element 0x0000 of private groups
-   dcmdir->SetLoadMode(NO_SEQ);
+   dcmdir->SetLoadMode(GDCM_NAME_SPACE::LD_NOSEQ);
    dcmdir->SetDirectoryName(dirName);
-   dcmdir->Load( );
+   dcmdir->Load();
 
-   dcmdir->SetStartMethod(StartMethod, (void *) NULL);
-   dcmdir->SetEndMethod(EndMethod);
-   
    if ( !dcmdir->GetFirstPatient() ) 
    {
       std::cout << "makeDicomDir: no patient found. Exiting."
                 << std::endl;
 
-      delete dcmdir;
+      dcmdir->Delete();
       return 1;
    }
     
    // Create the corresponding DicomDir
-   dcmdir->WriteDicomDir("NewDICOMDIR");
-   delete dcmdir;
+   dcmdir->Write("NewDICOMDIR");
+   dcmdir->Delete();
 
    // Read from disc the just written DicomDir
-   gdcm::DicomDir *newDicomDir = new gdcm::DicomDir();
+   GDCM_NAME_SPACE::DicomDir *newDicomDir = GDCM_NAME_SPACE::DicomDir::New();
    newDicomDir->SetFileName("NewDICOMDIR");
    newDicomDir->Load();
 
@@ -97,7 +150,7 @@ int TestMakeDicomDir(int argc, char *argv[])
                <<" is not readable"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return 1;
    }
 
@@ -107,11 +160,11 @@ int TestMakeDicomDir(int argc, char *argv[])
                <<" has no patient"<<std::endl
                <<"          ...Failed"<<std::endl;
 
-      delete newDicomDir;
+      newDicomDir->Delete();
       return(1);
    }
 
    std::cout<<std::flush;
-   delete newDicomDir;
+   newDicomDir->Delete();
    return 0;
 }