system/UniqueFileDescriptor: make the base class public

This commit is contained in:
Max Kellermann 2018-08-20 16:38:27 +02:00
parent a65d02d3ae
commit 5e512763d3

View File

@ -34,10 +34,12 @@
#include <utility>
#include <assert.h>
/**
* An OO wrapper for a UNIX file descriptor.
*/
class UniqueFileDescriptor : protected FileDescriptor {
class UniqueFileDescriptor : public FileDescriptor {
public:
UniqueFileDescriptor() noexcept
:FileDescriptor(FileDescriptor::Undefined()) {}
@ -51,6 +53,8 @@ public:
explicit UniqueFileDescriptor(FileDescriptor _fd) noexcept
:FileDescriptor(_fd) {}
UniqueFileDescriptor(const UniqueFileDescriptor &) = delete;
UniqueFileDescriptor(UniqueFileDescriptor &&other) noexcept
:FileDescriptor(other.Steal()) {}
@ -63,20 +67,6 @@ public:
return *this;
}
/**
* Convert this object to its #FileDescriptor base type.
*/
const FileDescriptor &ToFileDescriptor() const noexcept {
return *this;
}
using FileDescriptor::IsDefined;
#ifndef _WIN32
using FileDescriptor::IsValid;
#endif
using FileDescriptor::Get;
using FileDescriptor::Steal;
protected:
void Set(int _fd) noexcept {
assert(!IsDefined());
@ -86,57 +76,17 @@ protected:
}
public:
using FileDescriptor::Open;
using FileDescriptor::OpenReadOnly;
#ifndef _WIN32
using FileDescriptor::OpenNonBlocking;
static bool CreatePipe(UniqueFileDescriptor &r, UniqueFileDescriptor &w) noexcept {
return FileDescriptor::CreatePipe(r, w);
}
using FileDescriptor::SetNonBlocking;
using FileDescriptor::SetBlocking;
using FileDescriptor::Duplicate;
using FileDescriptor::CheckDuplicate;
static bool CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept;
#endif
using FileDescriptor::EnableCloseOnExec;
using FileDescriptor::DisableCloseOnExec;
#ifdef USE_EVENTFD
using FileDescriptor::CreateEventFD;
#endif
#ifdef USE_SIGNALFD
using FileDescriptor::CreateSignalFD;
#endif
#ifdef HAVE_INOTIFY_INIT
using FileDescriptor::CreateInotify;
#endif
bool Close() noexcept {
return IsDefined() && FileDescriptor::Close();
}
using FileDescriptor::Rewind;
using FileDescriptor::Seek;
using FileDescriptor::Skip;
using FileDescriptor::Tell;
using FileDescriptor::GetSize;
using FileDescriptor::Read;
using FileDescriptor::Write;
#ifndef _WIN32
using FileDescriptor::Poll;
using FileDescriptor::WaitReadable;
using FileDescriptor::WaitWritable;
using FileDescriptor::IsReadyForWriting;
#endif
};
#endif