GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

gdcmBasicOffsetTable.h
Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004
    00005   Copyright (c) 2006-2011 Mathieu Malaterre
    00006   All rights reserved.
    00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00008
    00009      This software is distributed WITHOUT ANY WARRANTY; without even
    00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00011      PURPOSE.  See the above copyright notice for more information.
    00012
    00013 =========================================================================*/
    00014
    00015 #ifndef GDCMBASICOFFSETTABLE_H
    00016 #define GDCMBASICOFFSETTABLE_H
    00017
    00018 #include "gdcmFragment.h"
    00019
    00020 namespace gdcm
    00021 {
    00026 class GDCM_EXPORT BasicOffsetTable : public Fragment
    00027 {
    00028 //protected:
    00029 //  void SetTag(const Tag &t);
    00030 public:
    00031   BasicOffsetTable() : Fragment() {}
    00032   friend std::ostream &operator<<(std::ostream &os, const BasicOffsetTable &val);
    00033
    00034 /*
    00035   VL GetLength() const {
    00036     assert( !ValueLengthField.IsUndefined() );
    00037     assert( !ValueField || ValueField->GetLength() == ValueLengthField );
    00038     return TagField.GetLength() + ValueLengthField.GetLength()
    00039       + ValueLengthField;
    00040   }
    00041 */
    00042
    00043   template <typename TSwap>
    00044   std::istream &Read(std::istream &is) {
    00045     // Superclass
    00046     const Tag itemStart(0xfffe, 0xe000);
    00047     const Tag seqDelItem(0xfffe,0xe0dd);
    00048     if( !TagField.Read<TSwap>(is) )
    00049       {
    00050       assert(0 && "Should not happen");
    00051       return is;
    00052       }
    00053     //assert( TagField == itemStart );
    00054     if( TagField != itemStart )
    00055       {
    00056       // Bug_Siemens_PrivateIconNoItem.dcm
    00057       throw "SIEMENS Icon thingy";
    00058       }
    00059     if( !ValueLengthField.Read<TSwap>(is) )
    00060       {
    00061       assert(0 && "Should not happen");
    00062       return is;
    00063       }
    00064     // Self
    00065     SmartPointer<ByteValue> bv = new ByteValue;
    00066     bv->SetLength(ValueLengthField);
    00067     if( !bv->Read<TSwap>(is) )
    00068       {
    00069       assert(0 && "Should not happen");
    00070       return is;
    00071       }
    00072     ValueField = bv;
    00073     return is;
    00074     }
    00075
    00076 /*
    00077   template <typename TSwap>
    00078   std::ostream &Write(std::ostream &os) const {
    00079     const Tag itemStart(0xfffe, 0xe000);
    00080     const Tag seqDelItem(0xfffe,0xe0dd);
    00081     if( !TagField.Write<TSwap>(os) )
    00082       {
    00083       assert(0 && "Should not happen");
    00084       return os;
    00085       }
    00086     assert( TagField == itemStart );
    00087     if( !ValueLengthField.Write<TSwap>(os) )
    00088       {
    00089       assert(0 && "Should not happen");
    00090       return os;
    00091       }
    00092     if( ValueLengthField )
    00093       {
    00094       // Self
    00095       const ByteValue *bv = GetByteValue();
    00096       assert( bv );
    00097       assert( bv->GetLength() == ValueLengthField );
    00098       if( !bv->Write<TSwap>(os) )
    00099         {
    00100         assert(0 && "Should not happen");
    00101         return os;
    00102         }
    00103       }
    00104     return os;
    00105     }
    00106 */
    00107 };
    00108 //-----------------------------------------------------------------------------
    00109 inline std::ostream &operator<<(std::ostream &os, const BasicOffsetTable &val)
    00110 {
    00111   os << " BasicOffsetTable Length=" << val.ValueLengthField << std::endl;
    00112   if( val.ValueField )
    00113     {
    00114     const ByteValue *bv = val.GetByteValue();
    00115     assert( bv );
    00116     os << *bv;
    00117     }
    00118
    00119   return os;
    00120 }
    00121
    00122
    00123 } // end namespace gdcm
    00124
    00125 #endif //GDCMBASICOFFSETTABLE_H