]> Creatis software - gdcm.git/blobdiff - src/gdcmSQItem.cxx
Fix compile warning
[gdcm.git] / src / gdcmSQItem.cxx
index 6a3ea4611dd37e02ff8f7685526d4a5d43c434a2..7ca6d20260f73dd09e72b3fce3ca809c2cc6585b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/19 08:55:09 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2005/01/24 16:10:53 $
+  Version:   $Revision: 1.57 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -96,6 +96,8 @@ void SQItem::Print(std::ostream &os, std::string const &)
 
 /*
  * \brief   canonical Writer
+ * @param fp     file pointer to an already open file. 
+ * @param filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)
  */
 void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
 {
@@ -145,6 +147,7 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
 // Public
 /**
  * \brief   adds any Entry (Dicom Element) to the Sequence Item
+ * @param entry Entry to add
  */
 bool SQItem::AddEntry(DocEntry *entry)
 {
@@ -161,12 +164,12 @@ bool SQItem::AddEntry(DocEntry *entry)
  * \warning we suppose, right now, the element belongs to a Public Group
  *          (NOT a shadow one)       
  * @param   val string value to set
- * @param   group Group number of the searched tag.
+ * @param   group  Group number of the searched tag.
  * @param   elem Element number of the searched tag.
  * @return  true if element was found or created successfully
  */
 
-bool SQItem::SetEntry(std::string const &val, uint16_t group, 
+bool SQItem::SetEntryValue(std::string const &val, uint16_t group, 
                       uint16_t elem)
 {
    for(ListDocEntry::iterator i = DocEntries.begin(); 
@@ -190,7 +193,7 @@ bool SQItem::SetEntry(std::string const &val, uint16_t group,
          Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
          // if the invoked (group,elem) doesn't exist inside the Dictionary
          // we create a VirtualDictEntry
-         DictEntry *dictEntry = pubDict->GetDictEntry(group, elem);
+         DictEntry *dictEntry = pubDict->GetEntry(group, elem);
          if (dictEntry == NULL)
          {
             dictEntry = 
@@ -221,10 +224,8 @@ bool SQItem::SetEntry(std::string const &val, uint16_t group,
 }
 
 /**
- * \brief   Clear the hash table from given entry AND delete the entry.
+ * \brief   Clear the std::list from given entry AND delete the entry.
  * @param   entryToRemove Entry to remove AND delete.
- * \warning Some problems when using under Windows... prefer the use of
- *          Initialize / GetNext methods
  * @return true if the entry was found and removed; false otherwise
  */
 bool SQItem::RemoveEntry( DocEntry* entryToRemove)
@@ -236,17 +237,17 @@ bool SQItem::RemoveEntry( DocEntry* entryToRemove)
       if( *it == entryToRemove)
       {
          DocEntries.erase(it);
-         gdcmVerboseMacro( "One element erased.");
+         gdcmVerboseMacro( "One element erased: " << entryToRemove->GetKey() );
          delete entryToRemove;
          return true;
       }
    }
-   gdcmVerboseMacro( "Value not present.");
+   gdcmVerboseMacro( "Entry not found: " << entryToRemove->GetKey() );
    return false ;
 }
 
 /**
- * \brief   Clear the hash table from given entry BUT keep the entry.
+ * \brief   Clear the std::list from given entry BUT keep the entry.
  * @param   entryToRemove Entry to remove.
  * @return true if the entry was found and removed; false otherwise
  */
@@ -259,17 +260,18 @@ bool SQItem::RemoveEntryNoDestroy(DocEntry* entryToRemove)
       if( *it == entryToRemove)
       {
          DocEntries.erase(it);
-         gdcmVerboseMacro( "One element erased.");
+         gdcmVerboseMacro( "One element erased, no destroyed: "
+                            << entryToRemove->GetKey() );
          return true;
       }
    }
                                                                                 
-   gdcmVerboseMacro( "Value not present.");
+   gdcmVerboseMacro( "Entry not found:" << entryToRemove->GetKey() );
    return false ;
 }
                                                                                 
 /**
- * \brief   Get the first entry while visiting the SQItem
+ * \brief   Get the first Dicom entry while visiting the SQItem
  * \return  The first DocEntry if found, otherwhise 0
  */
 DocEntry * SQItem::GetFirstEntry()
@@ -281,12 +283,12 @@ DocEntry * SQItem::GetFirstEntry()
 }
                                                                                 
 /**
- * \brief   Get the next entry while visiting the chained list
+ * \brief   Get the next Dicom entry while visiting the chained list
  * \return  The next DocEntry if found, otherwhise NULL
  */
 DocEntry *SQItem::GetNextEntry()
 {
-   gdcmAssertMacro (ItDocEntries != DocEntries.end());
+  // gdcmAssertMacro (ItDocEntries != DocEntries.end());
    {
       ++ItDocEntries;
       if (ItDocEntries != DocEntries.end())
@@ -299,7 +301,7 @@ DocEntry *SQItem::GetNextEntry()
 // Protected
 /**
  * \brief   Gets a Dicom Element inside a SQ Item Entry
- * @param   group   Group number of the Entry
+ * @param   group Group number of the Entry
  * @param   elem  Element number of the Entry
  * @return Entry whose (group,elem) was passed. 0 if not found
  */
@@ -318,7 +320,7 @@ DocEntry *SQItem::GetDocEntry(uint16_t group, uint16_t elem)
 
 /**
  * \brief   Gets a Dicom Element inside a SQ Item Entry
- * @param   group   Group number of the Entry
+ * @param   group Group number of the Entry
  * @param   elem  Element number of the Entry
  * @return Entry whose (group,elem) was passed. 0 if not found
  */
@@ -369,15 +371,29 @@ SeqEntry* SQItem::GetSeqEntry(uint16_t group, uint16_t elem)
  *           GDCM_UNFOUND if not found
  */ 
 
-std::string SQItem::GetEntry(uint16_t group, uint16_t elem)
+std::string SQItem::GetEntryValue(uint16_t group, uint16_t elem)
 {
+
+/*
+   DocEntry *e = GetFirstEntry();
+   while (e)
+   {
+      if ( e->GetGroup() == group && e->GetElement() == elem)
+      {
+
+         if (ValEntry *ve = dynamic_cast<ValEntry*>(e))
+            return ve->GetValue();
+      }
+      e = GetNextEntry();
+   }   
+*/
    for(ListDocEntry::iterator i = DocEntries.begin();
                               i != DocEntries.end(); ++i)
    {
       if ( (*i)->GetGroup() == group && (*i)->GetElement() == elem)
       {
-         if (ValEntry *e = dynamic_cast<ValEntry*>(*i))
-            return e->GetValue();
+         if (ValEntry *ve = dynamic_cast<ValEntry*>(*i))
+           return ve->GetValue();
       }
    }
    return GDCM_UNFOUND;