LLDB  mainline
IOObject.h
Go to the documentation of this file.
1 //===-- IOObject.h ----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_Host_Common_IOObject_h_
10 #define liblldb_Host_Common_IOObject_h_
11 
12 #include <stdarg.h>
13 #include <stdio.h>
14 #include <sys/types.h>
15 
16 #include "lldb/lldb-private.h"
17 
18 namespace lldb_private {
19 
20 class IOObject {
21 public:
22  typedef enum {
23  eFDTypeFile, // Other FD requiring read/write
24  eFDTypeSocket, // Socket requiring send/recv
25  } FDType;
26 
27  // TODO: On Windows this should be a HANDLE, and wait should use
28  // WaitForMultipleObjects
29  typedef int WaitableHandle;
30  static const WaitableHandle kInvalidHandleValue;
31 
32  IOObject(FDType type, bool should_close)
33  : m_fd_type(type), m_should_close_fd(should_close) {}
34  virtual ~IOObject();
35 
36  virtual Status Read(void *buf, size_t &num_bytes) = 0;
37  virtual Status Write(const void *buf, size_t &num_bytes) = 0;
38  virtual bool IsValid() const = 0;
39  virtual Status Close() = 0;
40 
41  FDType GetFdType() const { return m_fd_type; }
42 
43  virtual WaitableHandle GetWaitableHandle() = 0;
44 
45 protected:
46  FDType m_fd_type;
47  bool m_should_close_fd; // True if this class should close the file descriptor
48  // when it goes away.
49 
50 private:
51  DISALLOW_COPY_AND_ASSIGN(IOObject);
52 };
53 } // namespace lldb_private
54 
55 #endif
IOObject(FDType type, bool should_close)
Definition: IOObject.h:32
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual Status Read(void *buf, size_t &num_bytes)=0
FDType GetFdType() const
Definition: IOObject.h:41
static const WaitableHandle kInvalidHandleValue
Definition: IOObject.h:30
virtual WaitableHandle GetWaitableHandle()=0
virtual Status Close()=0
virtual Status Write(const void *buf, size_t &num_bytes)=0
An error handling class.
Definition: Status.h:44
virtual bool IsValid() const =0