GDCM: gdcmFileMetaInformation.h Source File

GDCM 3.0.26

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"
22#include "gdcmExplicitDataElement.h"
23
24namespace gdcm_ns
25{
40 class GDCM_EXPORT FileMetaInformation : public DataSet
41{
42public:
43 // FIXME: TransferSyntax::TS_END -> TransferSyntax::ImplicitDataElement
44 FileMetaInformation();
45 ~FileMetaInformation();
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 std::string GetMediaStorageAsString() const;
56
57 // FIXME: no virtual function means: duplicate code...
58 void Insert(const DataElement& de) {
59 if( de.GetTag().GetGroup() == 0x0002 )
60 {
61 InsertDataElement( de );
62 }
63 else
64 {
65 gdcmErrorMacro( "Cannot add element with group != 0x0002 in the file meta header: " << de );
66 }
67 }
68 void Replace(const DataElement& de) {
69 Remove(de.GetTag());
70 Insert(de);
71 }
72
74 std::istream &Read(std::istream &is);
75 std::istream &ReadCompat(std::istream &is);
76
78 std::ostream &Write(std::ostream &os) const;
79
81 void FillFromDataSet(DataSet const &ds);
82
84 const Preamble &GetPreamble() const { return P; }
85 Preamble &GetPreamble() { return P; }
86 void SetPreamble(const Preamble &p) { P = p; }
87
89 static void SetImplementationClassUID(const char * imp);
90 static void AppendImplementationClassUID(const char * imp);
91 static const char *GetImplementationClassUID();
92 static void SetImplementationVersionName(const char * version);
93 static const char *GetImplementationVersionName();
94 static void SetSourceApplicationEntityTitle(const char * title);
95 static const char *GetSourceApplicationEntityTitle();
96
97 FileMetaInformation(FileMetaInformation const& fmi) = default;
98 FileMetaInformation& operator=(const FileMetaInformation& fmi) = default;
99
100 VL GetFullLength() const {
101 return P.GetLength() + DataSet::GetLength<ExplicitDataElement>();
102 }
103
104protected:
105 void ComputeDataSetTransferSyntax(); // FIXME
106
107 template <typename TSwap>
108 std::istream &ReadCompatInternal(std::istream &is);
109
110 void Default();
111 void ComputeDataSetMediaStorageSOPClass();
112
113 TransferSyntax DataSetTS;
114 TransferSyntax::NegociatedType MetaInformationTS;
115 MediaStorage::MSType DataSetMS;
116
117protected:
118 static const char * GetFileMetaInformationVersion();
119 static const char * GetGDCMImplementationClassUID();
120 static const char * GetGDCMImplementationVersionName();
121 static const char * GetGDCMSourceApplicationEntityTitle();
122
123private:
124 Preamble P;
125
126//static stuff:
127 static const char GDCM_FILE_META_INFORMATION_VERSION[];
128 static const char GDCM_IMPLEMENTATION_CLASS_UID[];
129 static const char GDCM_IMPLEMENTATION_VERSION_NAME[];
130 static const char GDCM_SOURCE_APPLICATION_ENTITY_TITLE[];
131 static std::string ImplementationClassUID;
132 static std::string ImplementationVersionName;
133 static std::string SourceApplicationEntityTitle;
134};
135//-----------------------------------------------------------------------------
136 inline std::ostream& operator<<(std::ostream &os, const FileMetaInformation &val)
137{
138 os << val.GetPreamble() << std::endl;
139 val.Print( os );
140 return os;
141}
142
143} // end namespace gdcm_ns
144
145#endif //GDCMFILEMETAINFORMATION_H
gdcm::DataElement
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
gdcm::DataElement::GetTag
const Tag & GetTag() const
Get Tag.
Definition gdcmDataElement.h:67
gdcm::DataSet
Class to represent a Data Set (which contains Data Elements)
Definition gdcmDataSet.h:56
gdcm::DataSet::InsertDataElement
void InsertDataElement(const DataElement &de)
Definition gdcmDataSet.h:273
gdcm::DataSet::Remove
SizeType Remove(const Tag &tag)
Completely remove a dataelement from the dataset.
Definition gdcmDataSet.h:172
gdcm::DataSet::Print
void Print(std::ostream &os, std::string const &indent="") const
Definition gdcmDataSet.h:79
gdcm::DataSet::GetLength
VL GetLength() const
Definition gdcmDataSet.h:110
gdcm::FileMetaInformation::GetGDCMSourceApplicationEntityTitle
static const char * GetGDCMSourceApplicationEntityTitle()
gdcm::FileMetaInformation::GetImplementationClassUID
static const char * GetImplementationClassUID()
gdcm::FileMetaInformation::FileMetaInformation
FileMetaInformation()
gdcm::FileMetaInformation::SetPreamble
void SetPreamble(const Preamble &p)
Definition gdcmFileMetaInformation.h:86
gdcm::FileMetaInformation::GetPreamble
Preamble & GetPreamble()
Definition gdcmFileMetaInformation.h:85
gdcm::FileMetaInformation::DataSetMS
MediaStorage::MSType DataSetMS
Definition gdcmFileMetaInformation.h:115
gdcm::FileMetaInformation::FileMetaInformation
FileMetaInformation(FileMetaInformation const &fmi)=default
gdcm::FileMetaInformation::Insert
void Insert(const DataElement &de)
Definition gdcmFileMetaInformation.h:58
gdcm::FileMetaInformation::operator<<
friend std::ostream & operator<<(std::ostream &_os, const FileMetaInformation &_val)
Definition gdcmFileMetaInformation.h:136
gdcm::FileMetaInformation::FillFromDataSet
void FillFromDataSet(DataSet const &ds)
Construct a FileMetaInformation from an already existing DataSet:
gdcm::FileMetaInformation::GetDataSetTransferSyntax
const TransferSyntax & GetDataSetTransferSyntax() const
Definition gdcmFileMetaInformation.h:53
gdcm::FileMetaInformation::GetImplementationVersionName
static const char * GetImplementationVersionName()
gdcm::FileMetaInformation::SetDataSetTransferSyntax
void SetDataSetTransferSyntax(const TransferSyntax &ts)
gdcm::FileMetaInformation::MetaInformationTS
TransferSyntax::NegociatedType MetaInformationTS
Definition gdcmFileMetaInformation.h:114
gdcm::FileMetaInformation::GetMediaStorageAsString
std::string GetMediaStorageAsString() const
gdcm::FileMetaInformation::IsValid
bool IsValid() const
Definition gdcmFileMetaInformation.h:49
gdcm::FileMetaInformation::SetImplementationClassUID
static void SetImplementationClassUID(const char *imp)
Override the GDCM default values:
gdcm::FileMetaInformation::GetGDCMImplementationVersionName
static const char * GetGDCMImplementationVersionName()
gdcm::FileMetaInformation::GetMetaInformationTS
TransferSyntax::NegociatedType GetMetaInformationTS() const
Definition gdcmFileMetaInformation.h:51
gdcm::FileMetaInformation::ComputeDataSetMediaStorageSOPClass
void ComputeDataSetMediaStorageSOPClass()
gdcm::FileMetaInformation::~FileMetaInformation
~FileMetaInformation()
gdcm::FileMetaInformation::operator=
FileMetaInformation & operator=(const FileMetaInformation &fmi)=default
gdcm::FileMetaInformation::SetSourceApplicationEntityTitle
static void SetSourceApplicationEntityTitle(const char *title)
gdcm::FileMetaInformation::DataSetTS
TransferSyntax DataSetTS
Definition gdcmFileMetaInformation.h:113
gdcm::FileMetaInformation::Write
std::ostream & Write(std::ostream &os) const
Write.
gdcm::FileMetaInformation::ReadCompat
std::istream & ReadCompat(std::istream &is)
gdcm::FileMetaInformation::ComputeDataSetTransferSyntax
void ComputeDataSetTransferSyntax()
gdcm::FileMetaInformation::GetGDCMImplementationClassUID
static const char * GetGDCMImplementationClassUID()
gdcm::FileMetaInformation::ReadCompatInternal
std::istream & ReadCompatInternal(std::istream &is)
gdcm::FileMetaInformation::GetSourceApplicationEntityTitle
static const char * GetSourceApplicationEntityTitle()
gdcm::FileMetaInformation::Default
void Default()
gdcm::FileMetaInformation::GetFileMetaInformationVersion
static const char * GetFileMetaInformationVersion()
gdcm::FileMetaInformation::Read
std::istream & Read(std::istream &is)
Read.
gdcm::FileMetaInformation::SetImplementationVersionName
static void SetImplementationVersionName(const char *version)
gdcm::FileMetaInformation::GetFullLength
VL GetFullLength() const
Definition gdcmFileMetaInformation.h:100
gdcm::FileMetaInformation::Replace
void Replace(const DataElement &de)
Definition gdcmFileMetaInformation.h:68
gdcm::FileMetaInformation::GetPreamble
const Preamble & GetPreamble() const
Get Preamble.
Definition gdcmFileMetaInformation.h:84
gdcm::FileMetaInformation::GetMediaStorage
MediaStorage GetMediaStorage() const
gdcm::FileMetaInformation::AppendImplementationClassUID
static void AppendImplementationClassUID(const char *imp)
gdcm::MediaStorage
MediaStorage.
Definition gdcmMediaStorage.h:44
gdcm::MediaStorage::MSType
MSType
Definition gdcmMediaStorage.h:46
gdcm::Preamble
DICOM Preamble (Part 10)
Definition gdcmPreamble.h:27
gdcm::Tag::GetGroup
uint16_t GetGroup() const
Returns the 'Group number' of the given Tag.
Definition gdcmTag.h:55
gdcm::TransferSyntax
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
gdcm::TransferSyntax::NegociatedType
NegociatedType
Definition gdcmTransferSyntax.h:42
gdcm::VL
Value Length.
Definition gdcmVL.h:30
gdcm::VL::GetLength
VL GetLength() const
Definition gdcmVL.h:68
gdcmDataElement.h
gdcmDataSet.h
gdcmExplicitDataElement.h
gdcmMediaStorage.h
gdcmPreamble.h
gdcmErrorMacro
#define gdcmErrorMacro(msg)
Error this is pretty bad, more than just warning It could mean lost of data, something not handle....
Definition gdcmTrace.h:165
gdcmTransferSyntax.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34