1 //===-- IOObject.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Host_Common_IOObject_h_
11 #define liblldb_Host_Common_IOObject_h_
15 #include <sys/types.h>
17 #include "lldb/lldb-private.h"
19 namespace lldb_private {
26 eFDTypeFile, // Other FD requiring read/write
27 eFDTypeSocket, // Socket requiring send/recv
30 // TODO: On Windows this should be a HANDLE, and wait should use
31 // WaitForMultipleObjects
32 typedef int WaitableHandle;
33 static const WaitableHandle kInvalidHandleValue;
35 IOObject(FDType type, bool should_close)
37 , m_should_close_fd(should_close)
40 virtual ~IOObject() {}
42 virtual Error Read (void *buf, size_t &num_bytes) = 0;
43 virtual Error Write (const void *buf, size_t &num_bytes) = 0;
44 virtual bool IsValid() const = 0;
45 virtual Error Close() = 0;
47 FDType GetFdType() const { return m_fd_type; }
49 virtual WaitableHandle GetWaitableHandle() = 0;
53 bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
56 DISALLOW_COPY_AND_ASSIGN (IOObject);