File indexing completed on 2024-05-19 13:30:29
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 IIOEVENTLISTENER_H 0025 #define IIOEVENTLISTENER_H 0026 0027 #include "platform.h" 0028 #include "types.h" 0029 #include "iovaluetypes.h" 0030 0031 class IIoEventSource; 0032 0033 class IIoEventListener 0034 { 0035 public: 0036 virtual ~IIoEventListener(); 0037 0038 // Contract: from the first to the last call from this class to IIoEventSource, the FileDescriptor 0039 // may not change. Notably, when closing, which involves resetting the file descriptor, the listener must 0040 // remove itself frome the IIoEventSource BEFORE resetting (or closing) the file descriptor. 0041 // (If the listener closed the fd but did not reset its value - i.e. what FileDescriptor() returns - , 0042 // another part of the program could get the same numeric fd value, leading to clashes. So just 0043 // unregister before actually closing the fd.) 0044 0045 IIoEventSource *ioEventSource() const; 0046 uint32 ioInterest() const; 0047 virtual IO::Status handleIoReady(IO::RW rw) = 0; 0048 virtual FileDescriptor fileDescriptor() const = 0; 0049 0050 protected: 0051 void setIoInterest(uint32 ioRw); 0052 0053 private: 0054 friend class IIoEventSource; 0055 IIoEventSource *m_eventSource = nullptr; // set by IIoEventSource, read by this class 0056 uint32 m_ioInterest = 0; // set by this class, read by IIoEventSource 0057 }; 0058 0059 #endif // IIOEVENTLISTENER_H