Line data Source code
1 :
2 : /* Copyright (c) 2007-2013, Stefan Eilemann <eile@equalizergraphics.com>
3 : *
4 : * This file is part of Collage <https://github.com/Eyescale/Collage>
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 CO_BUFFER_CONNECTION_H
21 : #define CO_BUFFER_CONNECTION_H
22 :
23 : #include <co/connection.h> // base class
24 : #include <lunchbox/types.h>
25 :
26 : namespace co
27 : {
28 : namespace detail { class BufferConnection; }
29 :
30 : /** A proxy connection buffering outgoing data into a memory buffer. */
31 : class BufferConnection : public Connection
32 : {
33 : public:
34 : /** Construct a new buffer connection. @version 1.0 */
35 : CO_API BufferConnection();
36 :
37 : /** Destruct this buffer connection. @version 1.0 */
38 : CO_API virtual ~BufferConnection();
39 :
40 : /**
41 : * Flush the accumulated data, sending it to the given connection.
42 : * @version 1.0
43 : */
44 : CO_API void sendBuffer( ConnectionPtr connection );
45 :
46 : /** @return the internal data buffer. @version 1.0 */
47 : CO_API const lunchbox::Bufferb& getBuffer() const;
48 :
49 : /** @return the internal data buffer. @version 1.0 */
50 : CO_API lunchbox::Bufferb& getBuffer();
51 :
52 : /** @return the size of the accumulated data. @version 1.0 */
53 : CO_API uint64_t getSize() const;
54 :
55 : protected:
56 : /** @internal */
57 : //@{
58 0 : void readNB( void*, const uint64_t ) override { LBDONTCALL; }
59 0 : int64_t readSync( void*, const uint64_t, const bool ) override
60 0 : { LBDONTCALL; return -1; }
61 : CO_API int64_t write( const void* buffer,
62 : const uint64_t bytes) override;
63 :
64 0 : Notifier getNotifier() const override { LBDONTCALL; return 0; }
65 : //@}
66 :
67 : private:
68 : detail::BufferConnection* const _impl;
69 : };
70 :
71 : typedef lunchbox::RefPtr< BufferConnection > BufferConnectionPtr;
72 : typedef lunchbox::RefPtr< const BufferConnection > ConstBufferConnectionPtr;
73 : }
74 :
75 : #endif // CO_BUFFER_CONNECTION_H
|