Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Compression / Compressor.h
blob5bddb9cd6966dfd84c5c5b0d16f63352c37bbc12
1 // -*- C++ -*-
2 //=============================================================================
3 /**
4 * @file Compressor.h
6 * @author ACE version by
7 * @author Derek Dominish <derek.dominish@dsto.defence.gov.au>
8 */
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)
19 # 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
29 /**
30 * CompressorId from OMG Compression::CompressorId
31 * see $(TAO_ROOT)/tao/Compression.pidl
33 enum ACE_CompressorId
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
50 public:
51 ACE_CompressorId get_compressor_id() const;
53 ACE_UINT32 get_compression_level() const;
55 /**
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
66 * is not possible.
68 virtual ACE_UINT64 compress(const void *in_ptr,
69 ACE_UINT64 in_len,
70 void *out_ptr,
71 ACE_UINT64 max_out_len) = 0;
73 /**
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,
82 ACE_UINT64 in_len,
83 void *out_ptr,
84 ACE_UINT64 max_out_len) = 0;
86 /**
87 * Return the current compressed bytes statistics counter.
89 virtual ACE_UINT64 compressed_bytes() const;
91 /**
92 * Return the current uncompressed bytes statistics counter.
94 virtual ACE_UINT64 uncompressed_bytes() const;
96 /**
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;
108 protected:
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);
115 private:
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