IOObject.h revision 320543
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 19namespace lldb_private { 20 21class IOObject { 22public: 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 Status Read(void *buf, size_t &num_bytes) = 0; 38 virtual Status Write(const void *buf, size_t &num_bytes) = 0; 39 virtual bool IsValid() const = 0; 40 virtual Status Close() = 0; 41 42 FDType GetFdType() const { return m_fd_type; } 43 44 virtual WaitableHandle GetWaitableHandle() = 0; 45 46protected: 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 51private: 52 DISALLOW_COPY_AND_ASSIGN(IOObject); 53}; 54} // namespace lldb_private 55 56#endif 57