Collage  1.0.1
Object-Oriented C++ Network Library
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  virtual void readNB( void*, const uint64_t ) { LBDONTCALL; }
59  virtual int64_t readSync( void*, const uint64_t, const bool )
60  { LBDONTCALL; return -1; }
61  CO_API virtual int64_t write( const void* buffer, const uint64_t bytes);
62 
63  virtual Notifier getNotifier() const { LBDONTCALL; return 0; }
65 
66 private:
67  detail::BufferConnection* const _impl;
68 };
69 
70 typedef lunchbox::RefPtr< BufferConnection > BufferConnectionPtr;
71 typedef lunchbox::RefPtr< const BufferConnection > ConstBufferConnectionPtr;
72 }
73 
74 #endif // CO_BUFFER_CONNECTION_H
CO_API BufferConnection()
Construct a new buffer connection.
virtual int64_t readSync(void *, const uint64_t, const bool)
Finish reading data from the connection.
An interface definition for communication between hosts.
Definition: connection.h:60
CO_API const lunchbox::Bufferb & getBuffer() const
CO_API void sendBuffer(ConnectionPtr connection)
Flush the accumulated data, sending it to the given connection.
A proxy connection buffering outgoing data into a memory buffer.
CO_API uint64_t getSize() const
int Notifier
The Notifier used by the ConnectionSet to detect readiness of a Connection.
Definition: connection.h:246
virtual CO_API ~BufferConnection()
Destruct this buffer connection.
virtual void readNB(void *, const uint64_t)
Start a read operation on the connection.
virtual Notifier getNotifier() const
virtual CO_API int64_t write(const void *buffer, const uint64_t bytes)
Write data to the connection.
lunchbox::RefPtr< Connection > ConnectionPtr
A reference pointer for Connection pointers.
Definition: types.h:88