HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_SCFReader.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_SCFReader.h
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef UT_SCFREADER_H_
12 #define UT_SCFREADER_H_
13 
14 #include "UT_SCFCommon.h"
15 #include "UT_API.h"
16 #include "UT_IStream.h"
18 
19 /// Interface for reading Seekable Compressed Format (SCF) files.
21 {
22 public:
23  UT_SCFReader();
24  ~UT_SCFReader();
25 
26  /// Retrieves a stream that the uncompressed data can be read from.
27  /// it has been given the index if available and is fully seekable.
28  /// @param filename The name of the file to open
29  UT_IStream *getInputStream(const char* filename);
30 
31  /// Retrieves a stream that the uncompressed data can be read from.
32  /// it has been given the index if available and is fully seekable.
33  /// @param filename The stream to be used as raw input
34  /// @return the stream to read decompressed data from or NULL if
35  /// unable to open file.
36  ///
37  /// The input stream needs to exist for the lifetime of the blosc stream
38  /// returned. The UT_SCFReader doesn't take ownership of the input stream
39  /// passed in.
40  ///
41  /// The UT_SCFReader @b does maintain ownership of the stream returned.
42  /// You should not clear this stream unless you steal ownership of the
43  /// streams (see stealStreams()).
44  UT_IStream *getInputStream(UT_IStream* stream);
45 
46  /// Provided the SCFReader has already been opened with getInputStream,
47  /// this allows you to regain the filtered stream that it owns.
48  UT_IStream *getFilteredInputStream() const { return myFilteredInput; }
49 
50  /// The UT_SCFReader typically takes ownership of two streams
51  /// - the filter stream (which is used to read the data)
52  /// - a "sub-stream" of the compressed data from the input stream
53  /// The reader usually deletes these streams on closing/destruction. If
54  /// you steal these streams, then it's safe to destroy the UT_SCFReader.
55  /// Though you become responsible for deleting the streams.
56  ///
57  /// It's possible the stream pointers may be NULL pointers if there have
58  /// been errors, or they have been stolen already.
59  ///
60  /// @note You cannot steal streams if you acquired the input stream by
61  /// passing a filename.
62  void stealStreams(UT_IStream *&filter, UT_IStream *&substream);
63 
64  /// When you open a blosc stream, there are two
65 
66  /// Closes the reader.
67  void close();
68 
69 private:
70 
71  /// Creates the filtered input stream that users read from.
72  /// It verifies and reads the header, metadata and index.
73  bool prepareInputStream();
74 
75  /// Reads and verifies the magic number (assumed to be 4 characters)
76  /// (stream must be at corrent position)
77  bool verifyMagic(const char* magic);
78 
79  /// Reads the metadata section
80  bool readMetadata();
81 
82  /// Reads the index section
83  bool readIndexSection();
84 
85 
86 private:
87  /// Raw input from file
88  UT_IStream *myRawInput;
89 
90  /// Substream of just the compressed blocks section data
91  UT_IStream *mySubStream;
92 
93  /// Filtered input from compressed blocks section
94  UT_IStream *myFilteredInput;
95 
96  /// Starting position of compressed blocks
97  exint myStartOfCompressedBlocks;
98 
99  /// Ending position of compressed blocks
100  exint myEndOfCompressedBlocks;
101 
102  /// The index containing the locations of the blocks
104 
105  /// Length of metadata section
106  int64 myMetadataLength;
107 
108  /// @{
109  /// Flags to indicate whether the corresponding streams should be deleted
110  bool myDeleteRawInputStream;
111  bool myDeleteSubStream;
112  bool myDeleteFilteredInput;
113  /// @}
114 };
115 
116 #endif // UT_SCFREADER_H_
GLuint GLuint stream
Definition: glcorearb.h:1831
#define UT_API
Definition: UT_API.h:12
long long int64
Definition: SYS_Types.h:106
int64 exint
Definition: SYS_Types.h:115
virtual void close()
Interface for reading Seekable Compressed Format (SCF) files.
Definition: UT_SCFReader.h:20
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1296
UT_IStream * getFilteredInputStream() const
Definition: UT_SCFReader.h:48