Line data Source code
1 :
2 : /* Copyright (c) 2005-2014, 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_FDCONNECTION_H
21 : #define CO_FDCONNECTION_H
22 :
23 : #include <co/connection.h>
24 :
25 : namespace co
26 : {
27 : /** A generic file descriptor-based connection, to be subclassed. */
28 : class FDConnection : public Connection
29 : {
30 : public:
31 847 : Notifier getNotifier() const final { return _readFD; }
32 : protected:
33 : FDConnection();
34 349 : virtual ~FDConnection() {}
35 3016723 : void readNB(void*, const uint64_t) override { /* NOP */}
36 : int64_t readSync(void* buffer, const uint64_t bytes,
37 : const bool ignored) override;
38 : int64_t write(const void* buffer, const uint64_t bytes) override;
39 :
40 : int _readFD; //!< The read file descriptor.
41 : int _writeFD; //!< The write file descriptor.
42 :
43 : friend inline std::ostream& operator<<(std::ostream& os,
44 : const FDConnection* connection);
45 :
46 : private:
47 : int _getTimeOut();
48 : };
49 :
50 : inline std::ostream& operator<<(std::ostream& os,
51 : const FDConnection* connection)
52 : {
53 : return os << static_cast<const Connection*>(connection) << " readFD "
54 : << connection->_readFD << " writeFD " << connection->_writeFD;
55 : }
56 : }
57 :
58 : #endif // CO_FDCONNECTION_H
|