Line data Source code
1 :
2 : /* Copyright (c) 2013-2015, Stefan.Eilemann@epfl.ch
3 : *
4 : * This file is part of Pression <https://github.com/Eyescale/Pression>
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #ifndef PRESSION_COMPRESSORRESULT_H
21 : #define PRESSION_COMPRESSORRESULT_H
22 :
23 : #include <pression/plugins/compressorTypes.h> // EQ_COMPRESSOR_INVALID
24 : #include <lunchbox/array.h> // used inline as CompressorChunk
25 :
26 : namespace pression
27 : {
28 : /**
29 : * A structure to hold the results from one compress operation.
30 : *
31 : * Valid as long as the associated Compressor is valid and has not been used
32 : * again.
33 : */
34 185 : struct CompressorResult
35 : {
36 0 : CompressorResult() : compressor( EQ_COMPRESSOR_INVALID ) {}
37 185 : CompressorResult( const unsigned n, const CompressorChunks& c )
38 185 : : compressor( n ), chunks( c ) {}
39 :
40 : /** @return the aggregate size of all chunks @version 1.9.1 */
41 185 : uint64_t getSize() const
42 : {
43 185 : uint64_t size = 0;
44 553 : for( const CompressorChunk& chunk : chunks )
45 368 : size += chunk.getNumBytes();
46 185 : return size;
47 : }
48 :
49 : /** @return true if the result contains compressed data. @version 1.9.1 */
50 : bool isCompressed() const
51 : {
52 : return compressor != EQ_COMPRESSOR_INVALID &&
53 : compressor != EQ_COMPRESSOR_NONE &&
54 : compressor != EQ_COMPRESSOR_AUTO;
55 : }
56 :
57 : unsigned compressor;
58 : CompressorChunks chunks;
59 : };
60 : }
61 : #endif // PRESSION_COMPRESSORRESULT_H
|