cheshirekow  v0.1.0
fd_set.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (josh.bialkowski@gmail.com)
3  *
4  * This file is part of cpp-nix.
5  *
6  * cpp-nix is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * cpp-nix is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with cpp-nix. If not, see <http://www.gnu.org/licenses/>.
18  */
26 #ifndef CPP_NIX_FDSET_H_
27 #define CPP_NIX_FDSET_H_
28 
29 #include <vector>
30 #include <cstdlib>
31 #include <bitset>
32 #include <unistd.h>
33 
34 namespace nix {
35 
37 class FdSet : public fd_set {
38  public:
40  class Ref {
41  private:
42  fd_set* m_set;
43  int m_fd;
44 
45  friend class FdSet;
46  Ref(fd_set* set, int fd);
47 
48  public:
49  operator bool() const;
50  Ref& operator=(bool x);
51  Ref& flip();
52  };
53 
55  class ConstRef {
56  private:
57  const fd_set* m_set;
58  int m_fd;
59 
60  friend class FdSet;
61  ConstRef(const fd_set* set, int fd);
62 
63  public:
64  operator bool() const;
65  };
66 
67  public:
69  void clear();
70 
72  Ref operator[](unsigned int fd);
73  const ConstRef operator[](unsigned int fd) const;
74 };
75 
76 } // namespace nix
77 
78 #endif // FDSET_H_
an fd_set with array accessors
Definition: fd_set.h:37
void clear()
clears (zeros) the set
const fd_set * m_set
Definition: fd_set.h:57
reference to an element in a bitset
Definition: fd_set.h:40
ConstRef(const fd_set *set, int fd)
fd_set * m_set
Definition: fd_set.h:42
reference to an element in a bitset
Definition: fd_set.h:55
Ref(fd_set *set, int fd)
Ref & flip()
flip the bit
__host__ __device__ Scalar & set(LValue< Scalar, ROWS, COLS, Exp > &M)
Definition: Access.h:60
Ref operator[](unsigned int fd)
array operator
Ref & operator=(bool x)
assign from bool