LCOV - code coverage report
Current view: top level - lunchbox - compressorResult.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 8 9 88.9 %
Date: 2014-08-05 Functions: 3 4 75.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2013-2014, Stefan.Eilemann@epfl.ch
       3             :  *
       4             :  * This file is part of Lunchbox <https://github.com/Eyescale/Lunchbox>
       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 LUNCHBOX_COMPRESSORRESULT_H
      21             : #define LUNCHBOX_COMPRESSORRESULT_H
      22             : 
      23             : #include <lunchbox/array.h> // used inline as CompressorChunk
      24             : #include <lunchbox/plugins/compressorTypes.h> // EQ_COMPRESSOR_INVALID
      25             : 
      26             : namespace lunchbox
      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         152 : struct CompressorResult
      35             : {
      36           0 :     CompressorResult() : compressor( EQ_COMPRESSOR_INVALID ) {}
      37         152 :     CompressorResult( const unsigned n, const CompressorChunks& c )
      38         152 :         : compressor( n ), chunks( c ) {}
      39             : 
      40             :     /** @return the aggregate size of all chunks @version 1.9.1 */
      41         152 :     uint64_t getSize() const
      42             :     {
      43         152 :         uint64_t size = 0;
      44         718 :         BOOST_FOREACH( const CompressorChunk& chunk, chunks )
      45         566 :             size += chunk.getNumBytes();
      46         152 :         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  // LUNCHBOX_COMPRESSORRESULT_H

Generated by: LCOV version 1.10