Collage  1.0.1
Object-Oriented C++ Network Library
buffer.h
1 
2 /* Copyright (c) 2012, Daniel Nachbaur <danielnachbaur@gmail.com>
3  * 2012-2013, 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 #ifndef CO_BUFFER_H
22 #define CO_BUFFER_H
23 
24 #include <co/api.h>
25 #include <co/types.h>
26 
27 #include <lunchbox/buffer.h> // base class
28 #include <lunchbox/referenced.h> // base class
29 
30 
31 namespace co
32 {
33 namespace detail { class Buffer; }
34 
43 class Buffer : public lunchbox::Bufferb, public lunchbox::Referenced
44 {
45 public:
47  CO_API Buffer( BufferListener* listener = 0 );
48 
50  CO_API virtual ~Buffer();
51 
53  bool isFree() const { return getRefCount() == 0; }
54 
55 private:
56  detail::Buffer* const _impl;
57  LB_TS_VAR( _writeThread );
58 
59  virtual void notifyFree();
60 };
61 
62 std::ostream& operator << ( std::ostream&, const Buffer& );
63 }
64 
65 #endif //CO_BUFFER_H
bool isFree() const
Definition: buffer.h:53
A listener interface to buffer state changes.
CO_API Buffer(BufferListener *listener=0)
Construct a new buffer.
A receive buffer for a Connection.
Definition: buffer.h:43
virtual CO_API ~Buffer()
Destruct this buffer.