2 //=============================================================================
6 * @author ACE version by
7 * @author Derek Dominish <derek.dominish@dsto.defence.gov.au>
9 //=============================================================================
11 #ifndef ACE_COMPRESSOR_H
12 #define ACE_COMPRESSOR_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ACE_Compression_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/Guard_T.h"
23 #include "ace/Thread_Mutex.h"
24 #include "ace/Synch_Traits.h"
25 #include "ace/Copy_Disabled.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 * CompressorId from OMG Compression::CompressorId
31 * see $(TAO_ROOT)/tao/Compression.pidl
35 ACE_COMPRESSORID_NONE
= 0,
36 ACE_COMPRESSORID_GZIP
= 1,
37 ACE_COMPRESSORID_PKZIP
= 2,
38 ACE_COMPRESSORID_BZIP2
= 3,
39 ACE_COMPRESSORID_ZLIB
= 4,
40 ACE_COMPRESSORID_LZMA
= 5,
41 ACE_COMPRESSORID_LZO
= 6,
42 ACE_COMPRESSORID_RZIP
= 7,
43 ACE_COMPRESSORID_7X
= 8,
44 ACE_COMPRESSORID_XAR
= 9,
45 ACE_COMPRESSORID_RLE
= 10
48 class ACE_Compression_Export ACE_Compressor
51 ACE_CompressorId
get_compressor_id() const;
53 ACE_UINT32
get_compression_level() const;
56 * Compress the @a in_ptr buffer for @a in_len into the
57 * @a dest_ptr buffer with a maximum @a max_out_len. If the
58 * @a max_out_len is exhausted through the compress process
59 * then a value of -1 will be returned from the function,
60 * otherwise the return value will indicate the resultant
61 * @a out_ptr compressed buffer length.
63 * NOTE: it is advisable that the @max_out_len be slightly
64 * larger of the input @a in_len (i.e. x 1.1F) to cater
65 * for the possibility that a reduced compressed length
68 virtual ACE_UINT64
compress(const void *in_ptr
,
71 ACE_UINT64 max_out_len
) = 0;
74 * DeCompress the @a in_ptr buffer for @a in_len into the
75 * @a out_ptr buffer with a maximum @a max_out_len. If the
76 * @a max_out_len is exhausted during decompression
77 * then a value of -1 will be returned from the function,
78 * otherwise the return value will indicate the resultant
79 * @a out_ptr decompressed buffer length.
81 virtual ACE_UINT64
decompress(const void *in_ptr
,
84 ACE_UINT64 max_out_len
) = 0;
87 * Return the current compressed bytes statistics counter.
89 virtual ACE_UINT64
compressed_bytes() const;
92 * Return the current uncompressed bytes statistics counter.
94 virtual ACE_UINT64
uncompressed_bytes() const;
97 * Return the current compression ratio statistics.
99 virtual float compression_ratio() const;
102 * Reset the statistics to zero.
104 virtual void reset_stats();
106 virtual ~ACE_Compressor () = default;
109 ACE_Compressor(ACE_CompressorId compressor_id
,
110 ACE_UINT32 compression_level
= 0); // Must be inherited.
112 virtual void update_stats(ACE_UINT64 uncompressed_bytes
,
113 ACE_UINT64 compressed_bytes
);
116 ACE_CompressorId compressor_id_
;
117 ACE_UINT32 compression_level_
;
119 // Ensure we can lock with immutability (i.e. const)
120 mutable ACE_SYNCH_MUTEX mutex_
;
122 ACE_UINT64 compressed_bytes_
;
123 ACE_UINT64 uncompressed_bytes_
;
125 ACE_Compressor (const ACE_Compressor
&) = delete;
126 ACE_Compressor
& operator= (const ACE_Compressor
&) = delete;
129 ACE_END_VERSIONED_NAMESPACE_DECL
131 #if defined (__ACE_INLINE__)
132 #include "Compressor.inl"
133 #endif /* __ACE_INLINE__ */
135 #include /**/ "ace/post.h"
137 #endif // ACE_COMPRESSOR_H