Collage  1.7.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
29 {
30 class BufferConnection;
31 }
32 
35 {
36 public:
38  CO_API BufferConnection();
39 
41  CO_API virtual ~BufferConnection();
42 
47  CO_API void sendBuffer(ConnectionPtr connection);
48 
50  CO_API const lunchbox::Bufferb& getBuffer() const;
51 
53  CO_API lunchbox::Bufferb& getBuffer();
54 
56  CO_API uint64_t getSize() const;
57 
58 protected:
61  void readNB(void*, const uint64_t) override { LBDONTCALL; }
62  int64_t readSync(void*, const uint64_t, const bool) override
63  {
64  LBDONTCALL;
65  return -1;
66  }
67  CO_API int64_t write(const void* buffer, const uint64_t bytes) override;
68 
69  Notifier getNotifier() const override
70  {
71  LBDONTCALL;
72  return 0;
73  }
75 
76 private:
77  detail::BufferConnection* const _impl;
78 };
79 
80 typedef lunchbox::RefPtr<BufferConnection> BufferConnectionPtr;
81 typedef lunchbox::RefPtr<const BufferConnection> ConstBufferConnectionPtr;
82 }
83 
84 #endif // CO_BUFFER_CONNECTION_H
Notifier getNotifier() const override
int64_t readSync(void *, const uint64_t, const bool) override
Finish reading data from the connection.
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
lunchbox::RefPtr< Connection > ConnectionPtr
A reference pointer for Connection pointers.
Definition: types.h:93
An interface definition for communication between hosts.
Definition: connection.h:59
A proxy connection buffering outgoing data into a memory buffer.
void readNB(void *, const uint64_t) override
Start a read operation on the connection.