]> Creatis software - gdcm.git/commitdiff
Add verbosity, on demand
authorjpr <jpr>
Tue, 30 Oct 2007 14:55:20 +0000 (14:55 +0000)
committerjpr <jpr>
Tue, 30 Oct 2007 14:55:20 +0000 (14:55 +0000)
Example/exSerieHelper.cxx
Example/exXCoherentFileSet.cxx

index 195b9e1a0ab065e7055189e0037a08b44c13b562..5305fe4dbbe1c4287e4f5b63c72b8dbac784772e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exSerieHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/30 11:56:52 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2007/10/30 14:55:20 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include "gdcmDirList.h" // for FileList
 #include "gdcmDebug.h"
 #include <iostream>
+#include "gdcmArgMgr.h"
 
 int main(int argc, char *argv[])
-{  
-   GDCM_NAME_SPACE::SerieHelper *s;
+{
+   START_USAGE(usage)
+   "\n exSerieHelper :\n                                                      ",
+   "Example on how to use the methodes of gdcm::SerieHelper                   ",
+   "usage: exSerieHelper {dirin=inputDirectoryName}                           ",
+   "                       [ { [noshadowseq] | [noshadow][noseq] } ] [debug]  ",
+   "                                                                          ",
+   "       dirin : user wants to analyze *all* the files                      ",
+   "                            within the directory                          ",
+   "       noshadowseq: user doesn't want to load Private Sequences           ",
+   "       noshadow   : user doesn't want to load Private groups (odd number) ",
+   "       noseq      : user doesn't want to load Sequences                   ",
+   "       verbose    : user wants to run the program in 'verbose mode'       ",
+   "       warning    : user wants to run the program in 'warning mode'       ",   
+   "       debug      : developper wants to run the program in 'debug mode'   ",
+   FINISH_USAGE
+
+   // ----- Initialize Arguments Manager ------
   
-   std::string dirName; 
-   if (argc > 1) 
-      dirName = argv[1];    
-   else 
+   GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
+  
+   if (am->ArgMgrDefined("usage") || argc == 1) 
    {
-      dirName = GDCM_DATA_ROOT;
+      am->ArgMgrUsage(usage); // Display 'usage'
+      delete am;
+      return 0;
    }
 
-   if (argc > 2)
+   if (am->ArgMgrDefined("debug"))
       GDCM_NAME_SPACE::Debug::DebugOn();
+      
+   if (am->ArgMgrDefined("warning"))
+      GDCM_NAME_SPACE::Debug::WarningOn();      
+
+   bool verbose = ( 0 != am->ArgMgrDefined("verbose") );
+      
+   int loadMode = GDCM_NAME_SPACE::LD_ALL;
+   if ( am->ArgMgrDefined("noshadowseq") )
+      loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
+   else
+   {
+      if ( am->ArgMgrDefined("noshadow") )
+         loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW;
+      if ( am->ArgMgrDefined("noseq") )
+         loadMode |= GDCM_NAME_SPACE::LD_NOSEQ;
+   }
+   
+   const char *dirName  = am->ArgMgrGetString("dirin");
+   if (dirName == 0)
+   {
+       std::cout <<std::endl
+                 << "'dirin=' must be present;" 
+                 <<  std::endl;
+       am->ArgMgrUsage(usage); // Display 'usage'  
+       delete am;
+       return 0;
+   }
 
   
    std::cout << "Dir Name :[" << dirName << "]" << std::endl;
@@ -42,7 +87,9 @@ int main(int argc, char *argv[])
    // Sometimes using only SerieHelper is not enought !
    // See also exXcoherentFileSet
    //
-
+   
+   
+   GDCM_NAME_SPACE::SerieHelper *s;
    s = GDCM_NAME_SPACE::SerieHelper::New();
    s->SetLoadMode(GDCM_NAME_SPACE::LD_ALL);     // Load everything for each File
    //GDCM_NAME_SPACE::TagKey t(0x0020,0x0013);
@@ -50,13 +97,14 @@ int main(int argc, char *argv[])
                                               // restriction is true
    s->SetDirectory(dirName, true); // true : recursive exploration
 
-   std::cout << " ---------------------------------------- Finish parsing :["
-             << dirName << "]" << std::endl;
-
-   s->Print();
-   std::cout << " ---------------------------------------- Finish printing (1)"
-             << std::endl;
+   if (verbose) {
+      std::cout << " ---------------------------------------- Finish parsing :["
+                << dirName << "]" << std::endl;
 
+      s->Print();
+     std::cout << " ---------------------------------------- Finish printing (1)"
+                << std::endl;
+   }
 
    GDCM_NAME_SPACE::FileList::const_iterator it;
    GDCM_NAME_SPACE::FileList *l;
index 3604db0720227f0f0f7971dfb26327cea4f95367..42199db9c0a771632071eefa7ec9f8f1c7f77d65 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exXCoherentFileSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/10/24 08:03:10 $
-  Version:   $Revision: 1.14 $
+  Date:      $Date: 2007/10/30 14:55:20 $
+  Version:   $Revision: 1.15 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
    START_USAGE(usage)
    "\n exXCoherentFileSet :\n                                                 ",
    "Shows the various 'XCoherent' Filesets within a directory                 ",
-   "Optionaly copis the images in a Directories tree                          ",
+   "Optionaly copies the images in a Directories tree                         ",
    "usage: exXCoherentFileSet {dirin=inputDirectoryName}                      ",
    "                           dirout=outputDirectoryName                     ",
    "                       { tag=group-elem | pos | ori } [sort] [write]      ",