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 {
24 eFDTypeFile, // Other FD requiring read/write
25 eFDTypeSocket, // Socket requiring send/recv
28 // TODO: On Windows this should be a HANDLE, and wait should use
29 // WaitForMultipleObjects
30 typedef int WaitableHandle;
31 static const WaitableHandle kInvalidHandleValue;
33 IOObject(FDType type, bool should_close)
34 : m_fd_type(type), m_should_close_fd(should_close) {}
35 virtual ~IOObject() {}
37 virtual Error Read(void *buf, size_t &num_bytes) = 0;
38 virtual Error Write(const void *buf, size_t &num_bytes) = 0;
39 virtual bool IsValid() const = 0;
40 virtual Error Close() = 0;
42 FDType GetFdType() const { return m_fd_type; }
44 virtual WaitableHandle GetWaitableHandle() = 0;
48 bool m_should_close_fd; // True if this class should close the file descriptor
52 DISALLOW_COPY_AND_ASSIGN(IOObject);