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 :
28 : /** A generic file descriptor-based connection, to be subclassed. */
29 : class FDConnection : public Connection
30 : {
31 : public:
32 871 : Notifier getNotifier() const final { return _readFD; }
33 :
34 : protected:
35 : FDConnection();
36 361 : virtual ~FDConnection() {}
37 :
38 2157916 : void readNB( void*, const uint64_t ) override { /* NOP */ }
39 : int64_t readSync( void* buffer, const uint64_t bytes,
40 : const bool ignored ) override;
41 : int64_t write( const void* buffer,
42 : const uint64_t bytes ) override;
43 :
44 : int _readFD; //!< The read file descriptor.
45 : int _writeFD; //!< The write file descriptor.
46 :
47 : friend inline std::ostream& operator << ( std::ostream& os,
48 : const FDConnection* connection );
49 : private:
50 : int _getTimeOut();
51 :
52 : };
53 :
54 : inline std::ostream& operator << ( std::ostream& os,
55 : const FDConnection* connection )
56 : {
57 : return os << static_cast< const Connection* >( connection ) << " readFD "
58 : << connection->_readFD << " writeFD " << connection->_writeFD;
59 : }
60 : }
61 :
62 : #endif //CO_FDCONNECTION_H
|