Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / Compression / Base_Compressor.cpp
blobbc2c1528d24b936a6c89b0c4aa05c6fda65cd382
1 #include "tao/Compression/Base_Compressor.h"
3 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
5 namespace TAO
7 BaseCompressor::BaseCompressor (
8 ::Compression::CompressorFactory_ptr compressor_factory,
9 ::Compression::CompressionLevel compression_level)
10 : compression_level_ (compression_level),
11 compressor_factory_ (compressor_factory),
12 compressed_bytes_ (0),
13 uncompressed_bytes_ (0)
17 ::Compression::CompressorFactory_ptr
18 BaseCompressor::compressor_factory ()
20 return ::Compression::CompressorFactory::_duplicate (
21 compressor_factory_);
24 ::Compression::CompressionLevel
25 BaseCompressor::compression_level ()
27 return compression_level_;
30 ::CORBA::ULongLong
31 BaseCompressor::compressed_bytes ()
33 ::CORBA::ULongLong return_value = 0;
35 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, 0);
36 return_value = compressed_bytes_;
38 return return_value;
41 ::CORBA::ULongLong
42 BaseCompressor::uncompressed_bytes ()
44 ::CORBA::ULongLong return_value = 0;
46 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, 0);
47 return_value = uncompressed_bytes_;
49 return return_value;
52 ::Compression::CompressionRatio
53 BaseCompressor::compression_ratio ()
55 ::Compression::CompressionRatio return_value = 0;
57 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, 0);
58 if (this->uncompressed_bytes_ > 0)
60 return_value =
61 static_cast< ::Compression::CompressionRatio>
62 ((::Compression::CompressionRatio) this->compressed_bytes_ / this->uncompressed_bytes_);
65 return return_value;
68 void
69 BaseCompressor::update_stats (
70 ::CORBA::ULongLong uncompressed_bytes,
71 ::CORBA::ULongLong compressed_bytes)
73 ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
74 this->uncompressed_bytes_ += uncompressed_bytes;
75 this->compressed_bytes_ += compressed_bytes;
79 TAO_END_VERSIONED_NAMESPACE_DECL