CIODevice: Add a virtual did_update_fd() no notify subclasses of fd change.

This will allow subclasses to react when the file descriptor changes.
This commit is contained in:
Andreas Kling 2019-07-27 10:47:46 +02:00
parent 8ed078e5b2
commit 8f4fba95c0
Notes: sideshowbarker 2024-07-19 13:02:14 +09:00
2 changed files with 12 additions and 1 deletions

View file

@ -241,3 +241,12 @@ int CIODevice::printf(const char* format, ...)
va_end(ap);
return ret;
}
void CIODevice::set_fd(int fd)
{
if (m_fd == fd)
return;
m_fd = fd;
did_update_fd(fd);
}

View file

@ -56,11 +56,13 @@ public:
protected:
explicit CIODevice(CObject* parent = nullptr);
void set_fd(int fd) { m_fd = fd; }
void set_fd(int);
void set_mode(OpenMode mode) { m_mode = mode; }
void set_error(int error) { m_error = error; }
void set_eof(bool eof) { m_eof = eof; }
virtual void did_update_fd(int) {}
private:
bool populate_read_buffer();
bool can_read_from_fd() const;