]> Creatis software - gdcm.git/blobdiff - Testing/TestDict.cxx
Fix mistypings
[gdcm.git] / Testing / TestDict.cxx
index 6d5b4e207fe7bf7a3dde828beb0486c14b4ffda8..aa6b1ffd5f57106521535e3c5dcd0d923497cd49 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestDict.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/18 07:56:21 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2007/05/23 14:18:06 $
+  Version:   $Revision: 1.13 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <iostream>
 #include <iomanip>
 
-int TestDict(int , char* [])
-{  
+int TestDict(int , char *[])
+{ 
+
+   std::cout << "----- Test Default Dicom Dictionary : ----------" << std::endl;
+   // Just to improve test coverage:
+   GDCM_NAME_SPACE::Dict *tempDict = GDCM_NAME_SPACE::Dict::New("dummyFileNameThatDoesntExist");
+   // Default dict is supposed to be used.
+   tempDict->Print();
+   std::cout << "---- end Test Default Dicom Dictionary : -------" << std::endl;
+
+   // Lets delete it.
+   tempDict->Delete();
+
    // Print the DictSet
    std::cout<<"#######################################################\n";
-   gdcm::DictSet *dicts=gdcm::Global::GetDicts();
+   GDCM_NAME_SPACE::DictSet *dicts=GDCM_NAME_SPACE::Global::GetDicts();
    if(!dicts)
    {
       std::cout<<"DictSet hasn't be found... Failed\n";
@@ -36,22 +48,27 @@ int TestDict(int , char* [])
 
    std::cout<<"DictSet content :\n";
 
-   gdcm::Dict *d = dicts->GetFirstEntry();
+   GDCM_NAME_SPACE::Dict *d = dicts->GetFirstDict();
    if (!d)
    {
       std::cout << "Dictset is empty" << std::endl;
       return 1;
    }
+
+   std::cout << "----------- Print DictSet contents: ----------" << std::endl;
+   dicts->Print();
+   std::cout << "----------- End Print DictSet contents: ------" << std::endl;
+
    while (d)
    {
       std::cout << "------------- a Dict is found : ----------" << std::endl;
       d->Print();
-      d = dicts->GetNextEntry();
+      d = dicts->GetNextDict();
    }
 
    // Print the Dict (public)
    std::cout<<"#######################################################\n";
-   gdcm::Dict *pubDict=dicts->GetDefaultPubDict();
+   GDCM_NAME_SPACE::Dict *pubDict=dicts->GetDefaultPubDict();
    if(!pubDict)
    {
       std::cout<<"The public Dict hasn't be found... Failed\n";
@@ -64,8 +81,8 @@ int TestDict(int , char* [])
    std::cout<<"#######################################################\n";
    const int ENTRY_GR = 0x10;
    const int ENTRY_EL = 0x20;
-   std::string key=gdcm::DictEntry::TranslateToKey(ENTRY_GR,ENTRY_EL);
-   gdcm::DictEntry *entry=pubDict->GetDictEntry(ENTRY_GR,ENTRY_EL);
+   GDCM_NAME_SPACE::TagKey key = GDCM_NAME_SPACE::DictEntry::TranslateToKey(ENTRY_GR,ENTRY_EL);
+   GDCM_NAME_SPACE::DictEntry *entry=pubDict->GetEntry(ENTRY_GR,ENTRY_EL);
    if(!entry)
    {
       std::cout<<"The DictEntry hasn't be found... Failed\n";
@@ -79,9 +96,17 @@ int TestDict(int , char* [])
    entry=pubDict->GetFirstEntry();
    while(entry)
    {
-      entry->Print();
+      std::cout << std::hex << entry->GetGroup() << "|" << entry->GetElement()
+                << " [" << entry->GetVR() << "] - VM [" << entry->GetVM()
+                << "] : " << entry->GetName() << " ( " << entry->GetKey() << ")\n";
       entry=pubDict->GetNextEntry();
    }
 
+/*   // Let's play with DicEntry stuff !
+   // First, we try to break an Entry.
+   entry=pubDict->GetFirstEntry();
+   entry->SetVR("PN");
+   // Should warn us !*/
+
    return(0);
 }