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.
27 ML_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 &endianess,
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 
233 ML_END_NAMESPACE
234 
235 #endif // of __mlImageFormatTagList_H
236 
#define MLIMAGEFORMATBASE_EXPORT
Global and OS specific declarations for the MLImageFormatBase project.
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, not to be used, because it is subje...
Class defining a list of tags used in the MLImageFormat class.
bool checkTag(const std::string &tagName, MLldouble &val) const
Searches tag with name tagName in list and if it exists then its value is read into val and true is r...
MLuint getExpectedHeaderAndListSizeAsBinary() const
Returns the number of bytes which would be needed to store the header and tag list in memory before w...
bool checkTag(const std::string &tagName, MLdouble &val) const
Searches tag with name tagName in list and if it exists then its value is read into val and true is r...
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 index to first tag in list with 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)
Append image properties and other information to tagList.
MLuint getTagListSizeInBytes() const
Returns sum of sizes of all tag names and values of all tags including their terminating 0 characters...
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 extractImageProperties(PagedImage &props, MLint &endianess, std::string &compressorName, std::string &compressorVersion, MLImageFormatTagList &compressionTagList, MLImageFormatTagList &userTagList, MLImageFormatTagList &privateTagList, std::string &defaultVoxelValue, MLint &usesCheckSum, MLint &usesPartialPages)
Gets image properties from a non empty tag list, empty lists are considered okay, only safely found s...
MLErrorCode load(MLImageFormatAbstractFileHandle *fileHandle, MLint filePos=0)
Reads the tag list from start of open file given by valid file handle for a readable and open file.
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...
const MLImageFormatTag * findConstTag(const std::string &tagName) const
Returns pointer to first tag in list with name tagName or NULL if not found.
void tagListOut(std::ostream &ostr) const
Passes the tag list into a the stream ostr.
char * getHeaderAndListAsBinary(size_t &memSize, MLuint32 saveModeBits) const
Create a memory buffer and fill if first with a null-terminated versionStr followed by all tagNames a...
std::string getTagListAsString() const
Passes the tag list into a the string str.
MLImageFormatTagList()
Default constructor, setting name and value to empty strings.
static const MLImageFormatTagList & getDefaultEmptyTagList()
Returns a default empty tags list. Must be called cfirst time in dll-init.
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 tag with name tagName in list and if it exists then its value is read into val and true is r...
bool checkTag(const std::string &tagName, MLint &val) const
Searches tag with name tagName in list and if it exists then its value is read into val and true is r...
MLErrorCode extractImageProperties(MLImageFormatInfos &infos)
Gets all image properties of infos except of the.
Class defining a tag used in the MLImageFormat class.
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
long double MLldouble
Definition: mlTypeDefs.h:238
unsigned int MLuint32
Definition: mlTypeDefs.h:191
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:594
double MLdouble
Definition: mlTypeDefs.h:223
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578