2#include <NDEVR/Buffer.h>
3#include <NDEVR/Dictionary.h>
4#include <NDEVR/String.h>
5#include <NDEVR/Pointer.h>
6#define NDEVR_SUPPORTS_ZFP 0
72 template<
class t_type>
86 if (
sizeof(t_type) == 4)
88 else if (
sizeof(t_type) == 8)
92 if (
sizeof(t_type) / 2 == 4)
94 else if (
sizeof(t_type) / 2 == 8)
98 if (
sizeof(t_type) / 3 == 4)
100 else if (
sizeof(t_type) / 3 == 8)
104 if (
sizeof(t_type) / 4 == 4)
106 else if (
sizeof(t_type) / 4 == 8)
113 return compression_mode;
116 template<
class t_type,
class t_index_type,
class t_memory_allocator,
class t_memory_manager>
119 object.buffer_size = data.
size();
120 if (
object.buffer_size != 0)
122 object.compression_mode = Compressor::PickCompressionMode<t_type>(
object.compression_mode);
123 object.uncompressed_data = (
uint01*)data.
ptr();
124 object.uncompressed_size = data.
memSize();
125 switch (
object.compression_mode)
132 compression_data.
clear();
133 object.compressed_size = 0;
137 object.compressed_size = data.
memSize();
140 object.compressed_data = compression_data.
begin();
141 CompressData(
object);
143 compression_data.
setSize(cast<t_index_type>(
object.compressed_size));
148 compression_data.
clear();
152 template<
class t_index_type,
class t_memory_allocator,
class t_memory_manager>
160 locations[i] = info.
index;
162 Compress(
object, compression_data, locations);
165 template<
class t_type,
class t_index_type,
class t_memory_allocator,
class t_memory_manager>
171 Buffer<
decltype(t_type::Type())> combined_data;
174 sizes[i] = data[i].
size();
175 combined_data.addAll(data[i]);
177 compression_data.
clear();
182 Compress(*sub_obj, temp_compress, sizes);
183 compression_data += temp_compress;
185 Compress(
object, temp_compress, combined_data);
186 compression_data += temp_compress;
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
constexpr t_index_type size() const
Definition Buffer.hpp:823
decltype(auto) ptr()
Definition Buffer.hpp:387
void setSize(t_index_type new_size)
Definition Buffer.hpp:803
decltype(auto) begin()
Definition Buffer.hpp:402
t_index_type memSize() const
Definition Buffer.hpp:397
void clear()
Definition Buffer.hpp:422
Class which is designed to compress objects for writing to file. Typically objects are added then the...
Definition Compressor.h:70
static sint04 ZLibCompress(uint01 *compressed, const uint01 *uncompressed, size_t &compressed_size, size_t decompressed_size)
static void DecompressData(BinaryCompressionObject &data)
static Module ZLibModule()
static CompressedStringInfo AddString(BinaryCompressionObject &data, const String &string)
static sint04 ZLibDecompressFile(File src, File output_dir)
static uint04 GetStringLength(BinaryCompressionObject &data, uint04 index)
static void CompressData(BinaryCompressionObject &data)
static char * GetString(BinaryCompressionObject &data, uint04 index)
static char * GetString(BinaryCompressionObject &data, const Bounds< 1, uint04 > &bounds)
static std::enable_if< ObjectInfo< t_type >::Buffer >::type Compress(BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< t_type, t_index_type, t_memory_allocator, t_memory_manager > &data)
Definition Compressor.h:166
static CompressionMode PickCompressionMode(CompressionMode compression_mode=e_default_compression)
Definition Compressor.h:73
static std::enable_if<!ObjectInfo< t_type >::Buffer >::type Compress(BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< t_type, t_index_type, t_memory_allocator, t_memory_manager > &data)
Definition Compressor.h:117
static void CompressString(BinaryCompressionObject &object, Buffer< uint01 > &compression_data, const Buffer< String, t_index_type, t_memory_allocator, t_memory_manager > &data)
Definition Compressor.h:153
static sint04 ZLibDecompress(const uint01 *compressed, uint01 *uncompressed, size_t compressed_size, size_t &decompressed_size)
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
The core String class for the NDEVR API.
Definition String.h:69
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:64
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
CompressionMode
Logical information about the type of compression implemented or requested.
Definition Compressor.h:16
@ e_best_compression
Definition Compressor.h:22
@ e_floating_point_compression_1_fltp04
Definition Compressor.h:23
@ e_floating_point_compression_2_fltp04
Definition Compressor.h:24
@ e_default_compression
Definition Compressor.h:18
@ e_floating_point_compression_4_fltp08
Definition Compressor.h:30
@ e_floating_point_compression_3_fltp08
Definition Compressor.h:29
@ e_no_compression
Definition Compressor.h:17
@ e_floating_point_compression_2_fltp08
Definition Compressor.h:28
@ e_string_compression
Definition Compressor.h:20
@ e_floating_point_compression_4_fltp04
Definition Compressor.h:26
@ e_compression_count
Definition Compressor.h:32
@ e_floating_point_compression_1_fltp08
Definition Compressor.h:27
@ e_floating_point_compression_3_fltp04
Definition Compressor.h:25
@ e_best_speed
Definition Compressor.h:19
@ e_floating_point_compression
Definition Compressor.h:21
@ e_string_reference
Definition Compressor.h:31
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
A container for storing compressed data, typically used for File IO operations. Responsible for stori...
Definition Compressor.h:52
uint01 * compressed_data
Definition Compressor.h:56
uint08 compressed_size
Definition Compressor.h:57
Buffer< Bounds< 1, uint04 > > * m_string_size_info
Definition Compressor.h:61
uint01 * uncompressed_data
Definition Compressor.h:54
Dictionary< String, uint04 > * m_string_reference
Definition Compressor.h:60
uint08 uncompressed_size
Definition Compressor.h:55
String * m_strings
Definition Compressor.h:62
CompressionMode compression_mode
Definition Compressor.h:53
DynamicPointer< BinaryCompressionObject > compression_link
Definition Compressor.h:63
uint08 buffer_size
Definition Compressor.h:58
Contains information for referencing compressed strings.
Definition Compressor.h:42
Bounds< 1, uint04 > bounds
Definition Compressor.h:44
uint04 index
Definition Compressor.h:43
Base class for extensions, typically added as external DLL's that can modify or enhance the behavior ...
Definition ModuleManager.h:59
Information about the object.
Definition ObjectInfo.h:54