HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_SCFWriter.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_SCFWriter.h
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef UT_SCFWRITER_H_
12 #define UT_SCFWRITER_H_
13 
14 #include <SYS/SYS_BoostStreams.h>
15 
16 #include "UT_SCFCommon.h"
17 #include "UT_API.h"
18 #include "UT_String.h"
19 #include "UT_Compression.h"
20 
21 // Forward dels
23 
24 /// Interface for writing Seekable Compressed Format (SCF) files.
26 {
27 public:
28  UT_SCFWriter(bool doShuffleing = true,
29  exint typeSize = 4,
30  exint blockSize = 65536,
32  int compressionlevel = UT_SCF_BLOSC_COMPRESSION_LEVEL);
33  ~UT_SCFWriter();
34 
35  /// Sets the compression type for the compressed blocks section
36  /// of the SCF.
37  void setCompressionType(UT_CompressionType type);
38 
39  /// Set's the size of each block in the SCF.
40  /// The default block size is: <TODO: Fill this in with default block size>
41  void setBlockSize(exint blockSize);
42 
43  /// Retrieves an output stream to write uncompressed data into
44  /// the file. This is equivalent to open().
45  /// @param filename Filename to write to.
46  bios::filtering_ostream* getOutputStream(const char* filename);
47 
48  /// Retrieves an output stream to write uncompressed data into
49  /// the file. This is equivalent to open().
50  /// @param outStream Stream to write to.
51  bios::filtering_ostream* getOutputStream(std::ostream* outStream);
52 
53  /// Closes the file.
54  void close();
55 
56 private:
57 
58  /// Writes the header and metadata then opens the compressed
59  /// stream for writing
60  void initalizeOutput();
61 
62  /// Opens a filtering outstream with current options
63  void openCompressedBlocksStream();
64 
65  /// Writes header information to stream (also writes metadata)
66  /// Header is | Magic # = scf1 | Metadata Length |
67  void writeHeader();
68 
69  /// Writes the metadata section to stream
70  void writeMetadata();
71 
72  /// Writes the index including the footer data
73  void writeBlocksIndex(const UT_CompressedBlockIndex& index);
74 
75  /// Writes the footer data
76  /// Footer is | Index Length | Magic # = 1fcs |
77  void writeFooterData(int64 indexLength);
78 
79 private:
80  /// Flag set once stream is open
81  bool myIsActive;
82 
83  /// Compression type to use for compressed blocks section
84  UT_CompressionType myCompressionType;
85 
86  /// The block size for the compressed blocks section
87  exint myBlockSize;
88 
89  /// True if we should do shuffling (blosc only)
90  bool myDoShuffleing;
91 
92  /// Typesize for shuffling (blosc only)
93  exint myTypeSize;
94 
95  /// Compression level.
96  int myCompressionLevel;
97 
98  /// Our filtered output stream to compressed blocks section
99  bios::filtering_ostream* myFilteredOutput;
100 
101  /// Our raw output stream
102  std::ostream* myRawOutput;
103 
104  /// We somtimes create the output stream ourselfs, if we do
105  /// it is assigned here to be deleted.
106  std::ostream* myOutputToDelete;
107 };
108 
109 #endif // UT_SCFWRITER_H_
#define UT_API
Definition: UT_API.h:12
long long int64
Definition: SYS_Types.h:100
Interface for writing Seekable Compressed Format (SCF) files.
Definition: UT_SCFWriter.h:25
int64 exint
Definition: SYS_Types.h:109
UT_CompressionType
virtual void close()
GLuint index
Definition: glcorearb.h:785
#define UT_SCF_BLOSC_COMPRESSION_LEVEL
Definition: UT_SCFCommon.h:16
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107