| 1 |
/* This file is part of the FaCT++ DL reasoner |
| 2 |
Copyright (C) 2005-2015 Dmitry Tsarkov and The University of Manchester |
| 3 |
Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Lesser General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2.1 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public |
| 16 |
License along with this library; if not, write to the Free Software |
| 17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| •19 |
#include <cstdint> |
| 20 |
|
| 21 |
#ifndef FLAGS_Hcxx . . $ `Kernel/flags.h:22:9`! |
| 22 |
#define FLAGS_Hcxx . . $ `Kernel/flags.h:22:9`! |
| 23 |
|
| 24 |
/// class for carrying different flags; real users shall inherit from it |
| 25 |
class Flagscxx . . $ Flags# |
| 26 |
{ |
| 27 |
public: // types |
| 28 |
/// type of base integer used for bit-set |
| 29 |
typedef uint32_tcxx . . $ uint32_t# IntTypecxx . . $ Flags#IntType#; |
| 30 |
|
| 31 |
private: // members |
| 32 |
/// variable to keep all the flags |
| 33 |
IntTypecxx . . $ Flags#IntType# flagscxx . . $ Flags#flags. = 0; |
| 34 |
|
| 35 |
protected: // methods for flags maintenance |
| 36 |
/// get given flag value |
| 37 |
bool getFlagcxx . . $ Flags#getFlag(8de63fdb265b07c1). ( IntTypecxx . . $ Flags#IntType# mask ) const { return (flagscxx . . $ Flags#flags. & mask) != 0; } |
| 38 |
/// set given flag to 1 |
| 39 |
void setFlagcxx . . $ Flags#setFlag(cb2f890c2fdad230). ( IntTypecxx . . $ Flags#IntType# mask ) { flagscxx . . $ Flags#flags. |= mask; } |
| 40 |
/// set given flag to 0 |
| 41 |
void clearFlagcxx . . $ Flags#clearFlag(cb2f890c2fdad230). ( IntTypecxx . . $ Flags#IntType# mask ) { flagscxx . . $ Flags#flags. &= ~mask; } |
| 42 |
/// set given flag to given value |
| 43 |
void setFlagcxx . . $ Flags#setFlag(ee2069353d7cc01f). ( IntTypecxx . . $ Flags#IntType# mask, bool Set ) { Set ? setFlagcxx . . $ Flags#setFlag(cb2f890c2fdad230).(mask) : clearFlagcxx . . $ Flags#clearFlag(cb2f890c2fdad230).(mask); } |
| 44 |
|
| 45 |
/// get all the flags at once |
| 46 |
IntTypecxx . . $ Flags#IntType# getAllFlagscxx . . $ Flags#getAllFlags(ddd8539a2fcdd4ce). ( void ) const { return flagscxx . . $ Flags#flags.; } |
| 47 |
/// set all flags to a given value; @return old value of the flags |
| 48 |
IntTypecxx . . $ Flags#IntType# setAllFlagscxx . . $ Flags#setAllFlags(2141b656ce2cc063). ( IntTypecxx . . $ Flags#IntType# value ) { IntTypecxx . . $ Flags#IntType# old = flagscxx . . $ Flags#flags.; flagscxx . . $ Flags#flags. = value; return old; } |
| 49 |
|
| 50 |
public: // interface |
| 51 |
/// empty c'tor |
| 52 |
Flagscxx . . $ Flags#Flags(49f6e7a06ebc5aa8).() = default; |
| 53 |
/// init flags with given set of flags |
| 54 |
explicit Flagscxx . . $ Flags#Flags(cb2f890c2fdad230). ( IntTypecxx . . $ Flags#IntType# init ) : flagscxx . . $ Flags#flags.(init) {} |
| 55 |
/// copy c'tor |
| 56 |
Flagscxx . . $ Flags#Flags(76fd2885d36544b6). ( const Flagscxx . . $ Flags#& f ) = default; |
| 57 |
/// assignment |
| 58 |
Flagscxx . . $ Flags#& operatorcxx . . $ Flags#`operator=`(f236d6877f9a92ec). = ( const Flagscxx . . $ Flags#& f ) = default; |
| 59 |
/// empty d'tor |
| 60 |
virtual ~cxx . . $ Flags#`~Flags`(49f6e7a06ebc5aa8).Flagscxx . . $ Flags#() = default; |
| 61 |
}; // Flags |
| 62 |
|
| 63 |
// use this macro to create a new flag |
| 64 |
#define FPP_ADD_FLAGcxx . . $ `Kernel/flags.h:64:9`!(Name,Mask) \ |
| 65 |
bool is##Name ( void ) const \ |
| 66 |
{ return getFlag(Mask); } \ |
| 67 |
void set##Name ( void ) \ |
| 68 |
{ setFlag(Mask); } \ |
| 69 |
void clear##Name ( void ) \ |
| 70 |
{ clearFlag(Mask); } \ |
| 71 |
void set##Name ( bool action ) \ |
| 72 |
{ setFlag(Mask,action); } \ |
| 73 |
|
| 74 |
#endif |