]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Host/IOObject.h
Merge llvm, clang, lld and lldb trunk r300890, and update build glue.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Host / IOObject.h
1 //===-- IOObject.h ----------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_Host_Common_IOObject_h_
11 #define liblldb_Host_Common_IOObject_h_
12
13 #include <stdarg.h>
14 #include <stdio.h>
15 #include <sys/types.h>
16
17 #include "lldb/lldb-private.h"
18
19 namespace lldb_private {
20
21 class IOObject {
22 public:
23   typedef enum {
24     eFDTypeFile,   // Other FD requiring read/write
25     eFDTypeSocket, // Socket requiring send/recv
26   } FDType;
27
28   // TODO: On Windows this should be a HANDLE, and wait should use
29   // WaitForMultipleObjects
30   typedef int WaitableHandle;
31   static const WaitableHandle kInvalidHandleValue;
32
33   IOObject(FDType type, bool should_close)
34       : m_fd_type(type), m_should_close_fd(should_close) {}
35   virtual ~IOObject() {}
36
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;
41
42   FDType GetFdType() const { return m_fd_type; }
43
44   virtual WaitableHandle GetWaitableHandle() = 0;
45
46 protected:
47   FDType m_fd_type;
48   bool m_should_close_fd; // True if this class should close the file descriptor
49                           // when it goes away.
50
51 private:
52   DISALLOW_COPY_AND_ASSIGN(IOObject);
53 };
54 }
55
56 #endif