Collage  1.3.0
High-performance C++ library for developing object-oriented distributed applications.
bufferConnection.h
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 
32 {
33 public:
35  CO_API BufferConnection();
36 
38  CO_API virtual ~BufferConnection();
39 
44  CO_API void sendBuffer( ConnectionPtr connection );
45 
47  CO_API const lunchbox::Bufferb& getBuffer() const;
48 
50  CO_API lunchbox::Bufferb& getBuffer();
51 
53  CO_API uint64_t getSize() const;
54 
55 protected:
58  void readNB( void*, const uint64_t ) override { LBDONTCALL; }
59  int64_t readSync( void*, const uint64_t, const bool ) override
60  { LBDONTCALL; return -1; }
61  CO_API int64_t write( const void* buffer,
62  const uint64_t bytes) override;
63 
64  Notifier getNotifier() const override { LBDONTCALL; return 0; }
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
Notifier getNotifier() const override
CO_API int64_t write(const void *buffer, const uint64_t bytes) override
Write data to the connection.
int64_t readSync(void *, const uint64_t, const bool) override
Finish reading data from the connection.
CO_API void sendBuffer(ConnectionPtr connection)
Flush the accumulated data, sending it to the given connection.
CO_API BufferConnection()
Construct a new buffer connection.
CO_API uint64_t getSize() const
int Notifier
The Notifier used by the ConnectionSet to detect readiness of a Connection.
Definition: connection.h:245
Object-oriented network library.
Definition: barrier.h:27
CO_API const lunchbox::Bufferb & getBuffer() const
virtual CO_API ~BufferConnection()
Destruct this buffer connection.
An interface definition for communication between hosts.
Definition: connection.h:56
A proxy connection buffering outgoing data into a memory buffer.
void readNB(void *, const uint64_t) override
Start a read operation on the connection.
lunchbox::RefPtr< Connection > ConnectionPtr
A reference pointer for Connection pointers.
Definition: types.h:95