Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Flags.h
1 /*
2  * Flags class
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2019, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_UTIL_FLAGS_H_
22 #define ELM_UTIL_FLAGS_H_
23 
24 #include <elm/types.h>
25 
26 namespace elm {
27 
28 template <class T = t::uint32>
29 class Flags {
30 public:
31  inline Flags(T i = 0): m(i) { }
32  inline bool bit(int i) const { return (m & (1 << i)) != 0; }
33  inline void set(int i) { m |= 1 << i; }
34  inline void clear(int i) { m &= ~(1 << i); }
35  inline bool operator()(int i) const { return bit(i); }
36  inline bool operator[](int i) const { return bit(i); }
37 private:
38  T m;
39 };
40 
41 } // elm
42 
43 #endif /* ELM_UTIL_FLAGS_H_ */
elm::Flags::clear
void clear(int i)
Definition: Flags.h:34
elm::Flags
Definition: Flags.h:29
elm
Definition: adapter.h:26
elm::Flags::operator[]
bool operator[](int i) const
Definition: Flags.h:36
elm::Flags::bit
bool bit(int i) const
Definition: Flags.h:32
elm::Flags::Flags
Flags(T i=0)
Definition: Flags.h:31
elm::Flags::operator()
bool operator()(int i) const
Definition: Flags.h:35
elm::Flags::set
void set(int i)
Definition: Flags.h:33