# gdcmCSAHeader.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2009 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 #ifndef __gdcmCSAHeader_h
    00016 #define __gdcmCSAHeader_h
    00017
    00018 #include "gdcmTypes.h"
    00019 #include "gdcmDataSet.h"
    00020 #include "gdcmCSAElement.h"
    00021
    00022 namespace gdcm
    00023 {
    00024 /*
    00025  * Everything done in this code is for the sole purpose of writing interoperable
    00026  * software under Sect. 1201 (f) Reverse Engineering exception of the DMCA.
    00027  * If you believe anything in this code violates any law or any of your rights,
    00028  * please contact us (gdcm-developers@lists.sourceforge.net) so that we can
    00029  * find a solution.
    00030  */
    00031 //-----------------------------------------------------------------------------
    00032
    00033 class DataElement;
    00034 class PrivateTag;
    00061 class GDCM_EXPORT CSAHeader
    00062 {
    00063   friend std::ostream& operator<<(std::ostream &_os, const CSAHeader &d);
    00064 public :
    00065   CSAHeader():InternalDataSet(),InternalType(UNKNOWN),InterfileData(0) {};
    00066   ~CSAHeader() {};
    00067
    00069   typedef enum {
    00070     UNKNOWN = 0,
    00071     SV10,
    00072     NOMAGIC,
    00073     DATASET_FORMAT,
    00074     INTERFILE,
    00075     ZEROED_OUT
    00076   } CSAHeaderType;
    00077
    00078   template <typename TSwap>
    00079   std::istream &Read(std::istream &is);
    00080
    00081   template <typename TSwap>
    00082   const std::ostream &Write(std::ostream &os) const;
    00083
    00085   bool LoadFromDataElement(DataElement const &de);
    00086
    00088   void Print(std::ostream &os) const;
    00089
    00091   const DataSet& GetDataSet() const { return InternalDataSet; }
    00092
    00094   const char * GetInterfile() const { return InterfileData; }
    00095
    00098   CSAHeaderType GetFormat() const;
    00099
    00102   static const PrivateTag & GetCSAImageHeaderInfoTag();
    00103
    00106   static const PrivateTag & GetCSASeriesHeaderInfoTag();
    00107
    00110   static const PrivateTag & GetCSADataInfo();
    00111
    00114   const CSAElement &GetCSAElementByName(const char *name);
    00115
    00118   bool FindCSAElementByName(const char *name);
    00119
    00120 protected:
    00121   const CSAElement& GetCSAEEnd() const;
    00122
    00123 private:
    00124   std::set<CSAElement> InternalCSADataSet;
    00125   DataSet InternalDataSet;
    00126   CSAHeaderType InternalType;
    00127   Tag DataElementTag;
    00128   static CSAElement CSAEEnd;
    00129   const char *InterfileData;
    00130 };
    00131 //-----------------------------------------------------------------------------
    00132 inline std::ostream& operator<<(std::ostream &os, const CSAHeader &d)
    00133 {
    00134   d.Print( os );
    00135   return os;
    00136 }
    00137
    00138 } // end namespace gdcm
    00139 //-----------------------------------------------------------------------------
    00140 #endif //__gdcmCSAHeader_h