libtasks Documentation  1.6
io_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 ADTECH GmbH
3  * Licensed under MIT (https://github.com/adtechlabs/libtasks/blob/master/COPYING)
4  *
5  * Author: Andreas Pohl
6  */
7 
8 #ifndef _IO_BASE_H_
9 #define _IO_BASE_H_
10 
11 #include <unistd.h>
12 
16 class io_base {
17  public:
18  io_base() {}
19  io_base(int fd) : m_fd(fd) {}
20  virtual ~io_base() {}
21 
22  inline int fd() const { return m_fd; }
23 
24  virtual void close() {
25  if (m_fd > -1) {
26  ::close(m_fd);
27  m_fd = -1;
28  }
29  }
30 
31  protected:
32  int m_fd = -1;
33 };
34 
35 #endif // _IO_BASE_H_
io_base()
Definition: io_base.h:18
int m_fd
Definition: io_base.h:32
virtual void close()
Definition: io_base.h:24
virtual ~io_base()
Definition: io_base.h:20
int fd() const
Definition: io_base.h:22
Base class for socket and term.
Definition: io_base.h:16
io_base(int fd)
Definition: io_base.h:19