GDCM  2.2.0
gdcmFileMetaInformation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: GDCM (Grassroots DICOM). A DICOM library
4 
5  Copyright (c) 2006-2011 Mathieu Malaterre
6  All rights reserved.
7  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #ifndef GDCMFILEMETAINFORMATION_H
15 #define GDCMFILEMETAINFORMATION_H
16 
17 #include "gdcmPreamble.h"
18 #include "gdcmDataSet.h"
19 #include "gdcmDataElement.h"
20 #include "gdcmMediaStorage.h"
21 #include "gdcmTransferSyntax.h"
23 
24 namespace gdcm
25 {
41 {
42 public:
43  // FIXME: TransferSyntax::TS_END -> TransferSyntax::ImplicitDataElement
44  FileMetaInformation():DataSetTS(TransferSyntax::TS_END),MetaInformationTS(TransferSyntax::Unknown),DataSetMS(MediaStorage::MS_END) {}
46 
47  friend std::ostream &operator<<(std::ostream &_os, const FileMetaInformation &_val);
48 
49  bool IsValid() const { return true; }
50 
51  TransferSyntax::NegociatedType GetMetaInformationTS() const { return MetaInformationTS; }
52  void SetDataSetTransferSyntax(const TransferSyntax &ts);
53  const TransferSyntax &GetDataSetTransferSyntax() const { return DataSetTS; }
54  MediaStorage GetMediaStorage() const;
55 
56  // FIXME: no virtual function means: duplicate code...
57  void Insert(const DataElement& de) {
58  if( de.GetTag().GetGroup() == 0x0002 )
59  {
60  InsertDataElement( de );
61  }
62  else
63  {
64  gdcmErrorMacro( "Cannot add element with group != 0x0002 in the file meta header: " << de );
65  }
66  }
67  void Replace(const DataElement& de) {
68  Remove(de.GetTag());
69  Insert(de);
70  }
71 
73  std::istream &Read(std::istream &is);
74  std::istream &ReadCompat(std::istream &is);
75 
77  std::ostream &Write(std::ostream &os) const;
78 
80  void FillFromDataSet(DataSet const &ds);
81 
83  const Preamble &GetPreamble() const { return P; }
84  Preamble &GetPreamble() { return P; }
85  void SetPreamble(const Preamble &p) { P = p; }
86 
88  static void SetImplementationClassUID(const char * imp);
89  static void AppendImplementationClassUID(const char * imp);
90  static const char *GetImplementationClassUID();
91  static void SetImplementationVersionName(const char * version);
92  static const char *GetImplementationVersionName();
93  static void SetSourceApplicationEntityTitle(const char * title);
94  static const char *GetSourceApplicationEntityTitle();
95 
97  {
98  DataSetTS = fmi.DataSetTS;
99  MetaInformationTS = fmi.MetaInformationTS;
100  DataSetMS = fmi.DataSetMS;
101  }
102 
103  VL GetFullLength() const {
104  return P.GetLength() + DataSet::GetLength<ExplicitDataElement>();
105  }
106 
107 protected:
108  void ComputeDataSetTransferSyntax(); // FIXME
109 
110  template <typename TSwap>
111  std::istream &ReadCompatInternal(std::istream &is);
112 
113  void Default();
114  void ComputeDataSetMediaStorageSOPClass();
115 
119 
120 protected:
121  static const char * GetFileMetaInformationVersion();
122  static const char * GetGDCMImplementationClassUID();
123  static const char * GetGDCMImplementationVersionName();
124  static const char * GetGDCMSourceApplicationEntityTitle();
125 
126 private:
127  Preamble P;
128 
129 //static stuff:
130  static const char GDCM_FILE_META_INFORMATION_VERSION[];
131  static const char GDCM_IMPLEMENTATION_CLASS_UID[];
132  static const char GDCM_IMPLEMENTATION_VERSION_NAME[];
133  static const char GDCM_SOURCE_APPLICATION_ENTITY_TITLE[];
134  static std::string ImplementationClassUID;
135  static std::string ImplementationVersionName;
136  static std::string SourceApplicationEntityTitle;
137 };
138 //-----------------------------------------------------------------------------
139 inline std::ostream& operator<<(std::ostream &os, const FileMetaInformation &val)
140 {
141  os << val.GetPreamble() << std::endl;
142  val.Print( os );
143  return os;
144 }
145 
146 } // end namespace gdcm
147 
148 #endif //GDCMFILEMETAINFORMATION_H

Generated on Wed Jun 13 2012 20:40:37 for GDCM by doxygen 1.8.1
SourceForge.net Logo