Warning, file /sdk/dferry/transport/itransport.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 Copyright (C) 2013 Andreas Hartmetz <ahartmetz@gmail.com> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LGPL. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 0019 Alternatively, this file is available under the Mozilla Public License 0020 Version 1.1. You may obtain a copy of the License at 0021 http://www.mozilla.org/MPL/ 0022 */ 0023 0024 #ifndef ITRANSPORT_H 0025 #define ITRANSPORT_H 0026 0027 #include "iioeventlistener.h" 0028 #include "platform.h" 0029 #include "types.h" 0030 0031 #include <vector> 0032 0033 class ConnectAddress; 0034 class EventDispatcher; 0035 class ITransportListener; 0036 class SelectEventPoller; 0037 0038 class ITransport : public IIoEventListener 0039 { 0040 public: 0041 // An ITransport subclass must have a file descriptor after construction and it must not change 0042 // except to the invalid file descriptor when disconnected. 0043 ITransport(); 0044 ~ITransport() override; 0045 0046 // This listener interface is different from IIoEventSource / IIoEventListener because that one is 0047 // one source, several file descriptors, one file descriptor to one listener 0048 // this is one file descriptor, two channels, one channel (read or write) to one listener. 0049 void setReadListener(ITransportListener *listener); 0050 void setWriteListener(ITransportListener *listener); 0051 0052 virtual IO::Result read(byte *buffer, uint32 maxSize) = 0; 0053 virtual IO::Result readWithFileDescriptors(byte *buffer, uint32 maxSize, 0054 std::vector<int> *fileDescriptors); 0055 virtual IO::Result write(chunk data) = 0; 0056 virtual IO::Result writeWithFileDescriptors(chunk data, const std::vector<int> &fileDescriptors); 0057 0058 void close(); 0059 virtual bool isOpen() = 0; 0060 0061 uint32 supportedPassingUnixFdsCount() const { return m_supportedUnixFdsCount; } 0062 0063 IO::Status handleIoReady(IO::RW rw) override; 0064 0065 // factory method - creates a suitable subclass to connect to address 0066 static ITransport *create(const ConnectAddress &connectAddress); 0067 0068 protected: 0069 virtual void platformClose() = 0; 0070 uint32 m_supportedUnixFdsCount = 0; 0071 0072 private: 0073 void updateTransportIoInterest(); // "Transport" in name to avoid confusion with IIoEventSource 0074 friend class ITransportListener; 0075 friend class SelectEventPoller; 0076 0077 ITransportListener *m_readListener = nullptr; 0078 ITransportListener *m_writeListener = nullptr; 0079 }; 0080 0081 #endif // ITRANSPORT_H