MeVisLab Toolbox Reference
mlImageFormatTagList.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_IMAGE_FORMAT_TAG_LIST_H
14#define ML_IMAGE_FORMAT_TAG_LIST_H
15
18
19// Resolve platform independencies.
21
22#include "mlModuleIncludes.h"
23
24#include "mlImageFormatTag.h"
25
26// Implement everything in ML namespace.
27ML_START_NAMESPACE
28
30 class DataCompressor;
31
33 class MLImageFormatInfos;
34 class MLImageFormatAbstractFileHandle;
35
36 //----------------------------------------------------------------------
38 //----------------------------------------------------------------------
39 class MLIMAGEFORMATBASE_EXPORT MLImageFormatTagList : public std::vector<MLImageFormatTag>{
40 public:
41
42 //----------------------------------------------------------------------
43 // CPU specific storage order of data in memory.
44 //----------------------------------------------------------------------
45 static const MLint ML_LITTLE_ENDIAN ;
46 static const MLint ML_BIG_ENDIAN ;
47
48 //----------------------------------------------------------------------
50 //----------------------------------------------------------------------
51 static const std::string ML_DICOM_TAG_PREFIX;
52
53 //--------------------------------------------------------------------------------
55 //--------------------------------------------------------------------------------
56 static const std::string ML_TAG_LIST_SIZE_IN_BYTES_TAG;
57
58 //--------------------------------------------------------------------------------
60 //--------------------------------------------------------------------------------
62
63
64 //------------------------------------------------------------------
67 //------------------------------------------------------------------
68
71
75
77 void tagListOut(std::ostream &ostr) const;
78
80 std::string getTagListAsString() const;
81
84 const MLImageFormatTag *findConstTag(const std::string &tagName) const;
85
88 MLint findTagIdx(const std::string &tagName) const;
89
93 bool checkTag(const std::string &tagName, MLint &val) const;
94
98 bool checkTag(const std::string &tagName, std::string &val) const;
99
103 bool checkTag(const std::string &tagName, MLdouble &val) const;
104
108 bool checkTag(const std::string &tagName, MLldouble &val) const;
109
113
123 char* getHeaderAndListAsBinary(size_t &memSize,
124 MLuint32 saveModeBits) const;
125
136 MLuint filePos,
137 MLuint32 saveModeBits) const;
138
149
150
164 const DataCompressor *compressor,
165 const MLImageFormatTagList &compressionTagList,
166 const MLImageFormatTagList &userTagList,
167 const MLImageFormatTagList &privateTagList,
168 const std::string &defaultVoxelValue,
169 MLuint32 saveModeBits);
170
187 MLint &endianness,
188 std::string &compressorName,
189 std::string &compressorVersion,
190 MLImageFormatTagList &compressionTagList,
191 MLImageFormatTagList &userTagList,
192 MLImageFormatTagList &privateTagList,
193 std::string &defaultVoxelValue,
194 MLint &usesCheckSum,
195 MLint &usesPartialPages);
196
207
214 void appendSpecialTags(const std::string &numTagsTagName,
215 const std::string &tagNamePrefix,
216 const MLImageFormatTagList &sourceTagList);
217
228 MLErrorCode extractSpecialTags(const std::string &numTagsTagName,
229 const std::string &tagNamePrefix,
230 MLImageFormatTagList &targetTagList) const;
231 };
232
233ML_END_NAMESPACE
234
235#endif // of __mlImageFormatTagList_H
236
#define MLIMAGEFORMATBASE_EXPORT
Abstract base class for ML data compression algorithms.
A base class for abstract read/write access of the MLImageFileFormat.
A internal structure containing information about an opened file.
Class defining a list of tags used in the MLImageFormat class.
bool checkTag(const std::string &tagName, MLldouble &val) const
Searches the tag with the name tagName in the list and if it exists, then its value is read into val ...
MLuint getExpectedHeaderAndListSizeAsBinary() const
Returns the number of bytes that would be needed to store the header and tag list in memory before wr...
bool checkTag(const std::string &tagName, MLdouble &val) const
Searches the tag with the name tagName in the list and if it exists, then its value is read into val ...
static const std::string ML_TAG_LIST_SIZE_IN_BYTES_TAG
Name of first tag whose value denotes the size of the entire tag list size.
MLint findTagIdx(const std::string &tagName) const
Returns the index to the first tag in the list with the name tagName or -1 if not found or on failure...
static const MLint ML_LITTLE_ENDIAN
Little endian.
MLErrorCode appendImageProperties(const PagedImage &props, const DataCompressor *compressor, const MLImageFormatTagList &compressionTagList, const MLImageFormatTagList &userTagList, const MLImageFormatTagList &privateTagList, const std::string &defaultVoxelValue, MLuint32 saveModeBits)
Appends image properties and other information to tagList.
MLErrorCode extractImageProperties(PagedImage &props, MLint &endianness, std::string &compressorName, std::string &compressorVersion, MLImageFormatTagList &compressionTagList, MLImageFormatTagList &userTagList, MLImageFormatTagList &privateTagList, std::string &defaultVoxelValue, MLint &usesCheckSum, MLint &usesPartialPages)
Returns image properties from a non-empty tag list, empty lists are considered okay.
MLuint getTagListSizeInBytes() const
Returns the sum of sizes of all tag names and values of all tags including their terminating 0 charac...
MLErrorCode extractSpecialTags(const std::string &numTagsTagName, const std::string &tagNamePrefix, MLImageFormatTagList &targetTagList) const
Helper function to extract special tags in a standardized way from this tag list into a target tag li...
MLErrorCode load(MLImageFormatAbstractFileHandle *fileHandle, MLint filePos=0)
Reads the tag list from the start of the open file given by a valid file handle for a readable and op...
static const std::string ML_DICOM_TAG_PREFIX
Name prefix for all stored DICOM tags.
MLErrorCode save(MLImageFormatAbstractFileHandle *fileHandle, MLuint filePos, MLuint32 saveModeBits) const
Writes the tag list into an open and writable file to position filePos or to the current file positio...
void tagListOut(std::ostream &ostr) const
Passes the tag list into the stream ostr.
static const MLImageFormatTagList & getDefaultEmptyTagList()
Returns a default empty tags list. Must be called first time in DLL initialization.
std::string getTagListAsString() const
Passes the tag list into the string str.
MLImageFormatTagList()
Default constructor that is setting name and value to empty strings.
void appendSpecialTags(const std::string &numTagsTagName, const std::string &tagNamePrefix, const MLImageFormatTagList &sourceTagList)
Helper function to special tags in a standardized way to the tag list.
static const MLint ML_BIG_ENDIAN
Big endian.
bool checkTag(const std::string &tagName, std::string &val) const
Searches the tag with the name tagName in the list and if it exists, then its value is read into val ...
char * getHeaderAndListAsBinary(size_t &memSize, MLuint32 saveModeBits) const
Creates a memory buffer and fill if first with a NULL-terminated versionStr followed by all tagNames ...
bool checkTag(const std::string &tagName, MLint &val) const
Searches the tag with the name tagName in the list and if it exists, then its value is read into val ...
MLErrorCode extractImageProperties(MLImageFormatInfos &infos)
Returns all image properties of infos except of the.
const MLImageFormatTag * findConstTag(const std::string &tagName) const
Returns a pointer to the first tag in the list with the name tagName or NULL if not found.
Class defining a tag used in the MLImageFormat class.
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:715
long double MLldouble
Definition mlTypeDefs.h:231
unsigned int MLuint32
Definition mlTypeDefs.h:184
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:505
double MLdouble
Definition mlTypeDefs.h:216
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489