HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  UT_SCFWriter(const UT_SCFWriter &) = delete;
36  UT_SCFWriter &operator=(const UT_SCFWriter &) = delete;
37 
38  /// Sets the compression type for the compressed blocks section
39  /// of the SCF.
40  void setCompressionType(UT_CompressionType type);
41 
42  /// Set's the size of each block in the SCF.
43  /// The default block size is: <TODO: Fill this in with default block size>
44  void setBlockSize(exint blockSize);
45 
46  /// Retrieves an output stream to write uncompressed data into
47  /// the file. This is equivalent to open().
48  /// @param filename Filename to write to.
49  bios::filtering_ostream* getOutputStream(const char* filename);
50 
51  /// Retrieves an output stream to write uncompressed data into
52  /// the file. This is equivalent to open().
53  /// @param outStream Stream to write to.
54  bios::filtering_ostream* getOutputStream(std::ostream* outStream);
55 
56  /// Closes the file.
57  void close();
58 
59 private:
60 
61  /// Writes the header and metadata then opens the compressed
62  /// stream for writing
63  void initalizeOutput();
64 
65  /// Opens a filtering outstream with current options
66  void openCompressedBlocksStream();
67 
68  /// Writes header information to stream (also writes metadata)
69  /// Header is | Magic # = scf1 | Metadata Length |
70  void writeHeader();
71 
72  /// Writes the metadata section to stream
73  void writeMetadata();
74 
75  /// Writes the index including the footer data
76  void writeBlocksIndex(const UT_CompressedBlockIndex& index);
77 
78  /// Writes the footer data
79  /// Footer is | Index Length | Magic # = 1fcs |
80  void writeFooterData(int64 indexLength);
81 
82 private:
83  /// Flag set once stream is open
84  bool myIsActive;
85 
86  /// Compression type to use for compressed blocks section
87  UT_CompressionType myCompressionType;
88 
89  /// The block size for the compressed blocks section
90  exint myBlockSize;
91 
92  /// True if we should do shuffling (blosc only)
93  bool myDoShuffleing;
94 
95  /// Typesize for shuffling (blosc only)
96  exint myTypeSize;
97 
98  /// Compression level.
99  int myCompressionLevel;
100 
101  /// Our filtered output stream to compressed blocks section
102  bios::filtering_ostream* myFilteredOutput;
103 
104  /// Our raw output stream
105  std::ostream* myRawOutput;
106 
107  /// We somtimes create the output stream ourselfs, if we do
108  /// it is assigned here to be deleted.
109  std::ostream* myOutputToDelete;
110 };
111 
112 #endif // UT_SCFWRITER_H_
GT_API const UT_StringHolder filename
int64 exint
Definition: SYS_Types.h:125
#define UT_API
Definition: UT_API.h:14
void close() override
Interface for writing Seekable Compressed Format (SCF) files.
Definition: UT_SCFWriter.h:25
long long int64
Definition: SYS_Types.h:116
UT_CompressionType
LeafData & operator=(const LeafData &)=delete
GLuint index
Definition: glcorearb.h:786
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t blockSize(VULKAN_HPP_NAMESPACE::Format format)
#define UT_SCF_BLOSC_COMPRESSION_LEVEL
Definition: UT_SCFCommon.h:16
type
Definition: core.h:1059