LCOV - code coverage report
Current view: top level - co - buffer.cpp (source / functions) Hit Total Coverage
Test: Collage Lines: 21 26 80.8 %
Date: 2018-01-09 16:37:03 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         717 :     explicit Buffer(BufferListener* listener_)
      32         717 :         : listener(listener_)
      33         717 :         , free(true)
      34             :     {
      35         717 :     }
      36             : 
      37             :     BufferListener* const listener;
      38             :     bool free;
      39             : };
      40             : }
      41             : 
      42         717 : Buffer::Buffer(BufferListener* listener)
      43             :     : lunchbox::Bufferb()
      44             :     , lunchbox::Referenced()
      45         717 :     , _impl(new detail::Buffer(listener))
      46             : {
      47         717 : }
      48             : 
      49        2065 : Buffer::~Buffer()
      50             : {
      51         709 :     delete _impl;
      52        1356 : }
      53             : 
      54      116369 : void Buffer::notifyFree()
      55             : {
      56      116369 :     if (_impl->listener)
      57      116072 :         _impl->listener->notifyFree(this);
      58      116369 :     _impl->free = true;
      59      116369 : }
      60             : 
      61      141857 : bool Buffer::isFree() const
      62             : {
      63      141857 :     return _impl->free;
      64             : }
      65             : 
      66      116073 : void Buffer::setUsed()
      67             : {
      68      116073 :     _impl->free = false;
      69      116073 : }
      70             : 
      71           0 : std::ostream& operator<<(std::ostream& os, const Buffer& buffer)
      72             : {
      73           0 :     os << lunchbox::disableFlush << "Buffer[" << buffer.getRefCount() << "@"
      74           0 :        << &buffer << "]";
      75           0 :     buffer.printHolders(os);
      76           0 :     return os << lunchbox::enableFlush;
      77             : }
      78          63 : }

Generated by: LCOV version 1.11