LCOV - code coverage report
Current view: top level - co - buffer.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 21 26 80.8 %
Date: 2016-12-14 01:26:48 Functions: 9 10 90.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
       3             :  *               2012-2014, Stefan.Eilemann@epfl.ch
       4             :  *
       5             :  * This file is part of Collage <https://github.com/Eyescale/Collage>
       6             :  *
       7             :  * This library is free software; you can redistribute it and/or modify it under
       8             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       9             :  * by the Free Software Foundation.
      10             :  *
      11             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      12             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      13             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      14             :  * details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public License
      17             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      18             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             :  */
      20             : 
      21             : #include "buffer.h"
      22             : #include "bufferListener.h"
      23             : 
      24             : namespace co
      25             : {
      26             : namespace detail
      27             : {
      28             : class Buffer
      29             : {
      30             : public:
      31         624 :     explicit Buffer( BufferListener* listener_ )
      32         624 :         : listener( listener_ )
      33         624 :         , free( true )
      34         624 :     {}
      35             : 
      36             :     BufferListener* const listener;
      37             :     bool free;
      38             : };
      39             : }
      40             : 
      41         624 : Buffer::Buffer( BufferListener* listener )
      42             :     : lunchbox::Bufferb()
      43             :     , lunchbox::Referenced()
      44         624 :     , _impl( new detail::Buffer( listener ))
      45             : {
      46         624 : }
      47             : 
      48        1782 : Buffer::~Buffer()
      49             : {
      50         616 :     delete _impl;
      51        1166 : }
      52             : 
      53      118291 : void Buffer::notifyFree()
      54             : {
      55      118291 :     if( _impl->listener )
      56      117977 :         _impl->listener->notifyFree( this );
      57      118291 :     _impl->free = true;
      58      118291 : }
      59             : 
      60      147972 : bool Buffer::isFree() const
      61             : {
      62      147972 :     return _impl->free;
      63             : }
      64             : 
      65      117978 : void Buffer::setUsed()
      66             : {
      67      117978 :     _impl->free = false;
      68      117978 : }
      69             : 
      70           0 : std::ostream& operator << ( std::ostream& os, const Buffer& buffer )
      71             : {
      72           0 :     os << lunchbox::disableFlush << "Buffer[" << buffer.getRefCount() << "@"
      73           0 :        << &buffer << "]";
      74           0 :     buffer.printHolders( os );
      75           0 :     return os << lunchbox::enableFlush;
      76             : }
      77          66 : }

Generated by: LCOV version 1.11