GDCM 2.2.0

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

- File List
- File Members

gdcmFileMetaInformation.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 #ifndef GDCMFILEMETAINFORMATION_H
    00015 #define GDCMFILEMETAINFORMATION_H
    00016
    00017 #include "gdcmPreamble.h"
    00018 #include "gdcmDataSet.h"
    00019 #include "gdcmDataElement.h"
    00020 #include "gdcmMediaStorage.h"
    00021 #include "gdcmTransferSyntax.h"
    00022 #include "gdcmExplicitDataElement.h"
    00023
    00024 namespace gdcm
    00025 {
    00040 class GDCM_EXPORT FileMetaInformation : public DataSet
    00041 {
    00042 public:
    00043   // FIXME: TransferSyntax::TS_END -> TransferSyntax::ImplicitDataElement
    00044   FileMetaInformation():DataSetTS(TransferSyntax::TS_END),MetaInformationTS(TransferSyntax::Unknown),DataSetMS(MediaStorage::MS_END) {}
    00045  ~FileMetaInformation() { };
    00046
    00047   friend std::ostream &operator<<(std::ostream &_os, const FileMetaInformation &_val);
    00048
    00049   bool IsValid() const { return true; }
    00050
    00051   TransferSyntax::NegociatedType GetMetaInformationTS() const { return MetaInformationTS; }
    00052   void SetDataSetTransferSyntax(const TransferSyntax &ts);
    00053   const TransferSyntax &GetDataSetTransferSyntax() const { return DataSetTS; }
    00054   MediaStorage GetMediaStorage() const;
    00055
    00056   // FIXME: no virtual function means: duplicate code...
    00057   void Insert(const DataElement& de) {
    00058     if( de.GetTag().GetGroup() == 0x0002 )
    00059       {
    00060       InsertDataElement( de );
    00061       }
    00062     else
    00063       {
    00064       gdcmErrorMacro( "Cannot add element with group != 0x0002 in the file meta header: " << de );
    00065       }
    00066   }
    00067   void Replace(const DataElement& de) {
    00068     Remove(de.GetTag());
    00069     Insert(de);
    00070   }
    00071
    00073   std::istream &Read(std::istream &is);
    00074   std::istream &ReadCompat(std::istream &is);
    00075
    00077   std::ostream &Write(std::ostream &os) const;
    00078
    00080   void FillFromDataSet(DataSet const &ds);
    00081
    00083   const Preamble &GetPreamble() const { return P; }
    00084   Preamble &GetPreamble() { return P; }
    00085   void SetPreamble(const Preamble &p) { P = p; }
    00086
    00088   static void SetImplementationClassUID(const char * imp);
    00089   static void AppendImplementationClassUID(const char * imp);
    00090   static const char *GetImplementationClassUID();
    00091   static void SetImplementationVersionName(const char * version);
    00092   static const char *GetImplementationVersionName();
    00093   static void SetSourceApplicationEntityTitle(const char * title);
    00094   static const char *GetSourceApplicationEntityTitle();
    00095
    00096   FileMetaInformation(FileMetaInformation const &fmi):DataSet(fmi)
    00097     {
    00098     DataSetTS = fmi.DataSetTS;
    00099     MetaInformationTS = fmi.MetaInformationTS;
    00100     DataSetMS = fmi.DataSetMS;
    00101     }
    00102
    00103     VL GetFullLength() const {
    00104       return P.GetLength() + DataSet::GetLength<ExplicitDataElement>();
    00105     }
    00106
    00107 protected:
    00108   void ComputeDataSetTransferSyntax(); // FIXME
    00109
    00110   template <typename TSwap>
    00111   std::istream &ReadCompatInternal(std::istream &is);
    00112
    00113   void Default();
    00114   void ComputeDataSetMediaStorageSOPClass();
    00115
    00116   TransferSyntax DataSetTS;
    00117   TransferSyntax::NegociatedType MetaInformationTS;
    00118   MediaStorage::MSType DataSetMS;
    00119
    00120 protected:
    00121   static const char * GetFileMetaInformationVersion();
    00122   static const char * GetGDCMImplementationClassUID();
    00123   static const char * GetGDCMImplementationVersionName();
    00124   static const char * GetGDCMSourceApplicationEntityTitle();
    00125
    00126 private:
    00127   Preamble P;
    00128
    00129 //static stuff:
    00130   static const char GDCM_FILE_META_INFORMATION_VERSION[];
    00131   static const char GDCM_IMPLEMENTATION_CLASS_UID[];
    00132   static const char GDCM_IMPLEMENTATION_VERSION_NAME[];
    00133   static const char GDCM_SOURCE_APPLICATION_ENTITY_TITLE[];
    00134   static std::string ImplementationClassUID;
    00135   static std::string ImplementationVersionName;
    00136   static std::string SourceApplicationEntityTitle;
    00137 };
    00138 //-----------------------------------------------------------------------------
    00139 inline std::ostream& operator<<(std::ostream &os, const FileMetaInformation &val)
    00140 {
    00141   os << val.GetPreamble() << std::endl;
    00142   val.Print( os );
    00143   return os;
    00144 }
    00145
    00146 } // end namespace gdcm
    00147
    00148 #endif //GDCMFILEMETAINFORMATION_H