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 LLDB_UTILITY_IOOBJECT_H
10 #define LLDB_UTILITY_IOOBJECT_H
11 
12 #include <cstdarg>
13 #include <cstdio>
14 #include <sys/types.h>
15 
16 #include "lldb/lldb-private.h"
17 
18 namespace lldb_private {
19 
20 class IOObject {
21 public:
22  enum FDType {
23  eFDTypeFile, // Other FD requiring read/write
24  eFDTypeSocket, // Socket requiring send/recv
25  };
26 
27  // TODO: On Windows this should be a HANDLE, and wait should use
28  // WaitForMultipleObjects
29  typedef int WaitableHandle;
31 
32  IOObject(FDType type) : m_fd_type(type) {}
33  virtual ~IOObject();
34 
35  virtual Status Read(void *buf, size_t &num_bytes) = 0;
36  virtual Status Write(const void *buf, size_t &num_bytes) = 0;
37  virtual bool IsValid() const = 0;
38  virtual Status Close() = 0;
39 
40  FDType GetFdType() const { return m_fd_type; }
41 
42  virtual WaitableHandle GetWaitableHandle() = 0;
43 
44 protected:
46 
47 private:
48  IOObject(const IOObject &) = delete;
49  const IOObject &operator=(const IOObject &) = delete;
50 };
51 } // namespace lldb_private
52 
53 #endif
lldb_private::IOObject::operator=
const IOObject & operator=(const IOObject &)=delete
lldb_private::IOObject::Close
virtual Status Close()=0
lldb_private::IOObject::IsValid
virtual bool IsValid() const =0
lldb_private::IOObject::IOObject
IOObject(FDType type)
Definition: IOObject.h:32
lldb_private::IOObject::eFDTypeFile
@ eFDTypeFile
Definition: IOObject.h:23
lldb_private::IOObject::WaitableHandle
int WaitableHandle
Definition: IOObject.h:29
lldb_private::IOObject
Definition: IOObject.h:20
lldb-private.h
lldb_private::IOObject::FDType
FDType
Definition: IOObject.h:22
lldb_private::Status
Definition: Status.h:44
lldb_private::IOObject::Write
virtual Status Write(const void *buf, size_t &num_bytes)=0
lldb_private::IOObject::GetWaitableHandle
virtual WaitableHandle GetWaitableHandle()=0
lldb_private::IOObject::Read
virtual Status Read(void *buf, size_t &num_bytes)=0
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::IOObject::GetFdType
FDType GetFdType() const
Definition: IOObject.h:40
lldb_private::IOObject::kInvalidHandleValue
static const WaitableHandle kInvalidHandleValue
Definition: IOObject.h:30
lldb_private::IOObject::~IOObject
virtual ~IOObject()
lldb_private::IOObject::m_fd_type
FDType m_fd_type
Definition: IOObject.h:45
lldb_private::IOObject::eFDTypeSocket
@ eFDTypeSocket
Definition: IOObject.h:24