MeVisLab Toolbox Reference
mlImageFormatFileAccess.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2016, 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_FILE_ACCESS_H
14#define ML_IMAGE_FORMAT_FILE_ACCESS_H
15
16// Resolve platform dependencies.
18
19#include <mlTypeDefs.h>
20
22
27 {
28 public:
31
34
37 MLuint8* read(MLuint startPosition, MLuint numBytes);
38
42 virtual bool read(MLuint8* data, MLuint startPosition, MLuint numBytes) = 0;
43
45 virtual MLErrorCode write(MLuint startPos, const MLuint8 *data, size_t length) = 0;
46
48 virtual MLint64 getFileSize() = 0;
49
51 virtual MLErrorCode close() = 0;
52 };
53
56 {
57 public:
60
63
67 bool read(MLuint8* data, MLuint startPosition, MLuint numBytes) override;
68
70 MLErrorCode write(MLuint startPos, const MLuint8 *data, size_t length) override;
71
73 MLint64 getFileSize() override;
74
76 MLErrorCode close() override;
77
78 private:
79 int _fd;
80 };
81
82
84
85#endif
#define MLIMAGEFORMATBASE_EXPORT
Global and OS specific declarations for the MLImageFormatBase project.
A base class for abstract read/write access of the MLImageFileFormat.
virtual MLint64 getFileSize()=0
Returns the current complete file size.
virtual ~MLImageFormatAbstractFileHandle()
Destructor to clean up. Reimplement to close the file.
virtual MLErrorCode write(MLuint startPos, const MLuint8 *data, size_t length)=0
Write the given block.
virtual MLErrorCode close()=0
Closes the file.
virtual bool read(MLuint8 *data, MLuint startPosition, MLuint numBytes)=0
Reads the given block and returns true if numBytes have been read.
MLImageFormatAbstractFileHandle()
Standard constructor.
MLuint8 * read(MLuint startPosition, MLuint numBytes)
Convenience method that reads the given block and returns an array that needs to be freed by free().
Implements reading and writing from a given file descriptor.
bool read(MLuint8 *data, MLuint startPosition, MLuint numBytes) override
Reads the given block and returns true if numBytes have been read.
~MLImageFormatDiskFileHandle() override
Destructor to clean up.
MLint64 getFileSize() override
Returns the current complete file size. If an error occurs, a value <0 is returned.
MLImageFormatDiskFileHandle(int fd)
Standard constructor.
MLErrorCode close() override
Closes the file.
MLErrorCode write(MLuint startPos, const MLuint8 *data, size_t length) override
Write the given block.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:716
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
unsigned char MLuint8
Definition mlTypeDefs.h:109
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:506
INT64 MLint64
Include 64 bit integer support for Windows or Unix.
Definition mlTypeDefs.h:412