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