1 /* Box<ITV>::Status class declaration. 2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it> 3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com) 4 5 This file is part of the Parma Polyhedra Library (PPL). 6 7 The PPL is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published by the 9 Free Software Foundation; either version 3 of the License, or (at your 10 option) any later version. 11 12 The PPL is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software Foundation, 19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. 20 21 For the most up-to-date information see the Parma Polyhedra Library 22 site: http://bugseng.com/products/ppl/ . */ 23 24 #ifndef PPL_Box_Status_idefs_hh 25 #define PPL_Box_Status_idefs_hh 1 26 27 #ifndef PPL_IN_Box_CLASS 28 #error "Do not include Box_Status_idefs.hh directly; use Box_defs.hh instead" 29 #endif 30 31 //! A conjunctive assertion about a Box<ITV> object. 32 /*! \ingroup PPL_CXX_interface 33 The assertions supported are: 34 - <EM>empty up-to-date</EM>: the empty flag is meaningful; 35 - <EM>empty</EM>: the box is the empty set. 36 - <EM>universe</EM>: the box is universe \f$n\f$-dimensional vector space 37 \f$\Rset^n\f$. 38 39 Not all the conjunctions of these elementary assertions constitute 40 a legal Status. In fact: 41 - <EM>empty up-to-date</EM> and <EM>empty</EM> excludes <EM>universe</EM>. 42 */ 43 class Status; 44 45 class Status { 46 public: 47 //! By default Status is the empty set of assertion. 48 Status(); 49 50 //! Ordinary copy constructor. 51 Status(const Status& y); 52 53 //! Copy constructor from a box of different type. 54 template <typename Other_ITV> 55 Status(const typename Box<Other_ITV>::Status& y); 56 57 //! \name Test, remove or add an individual assertion from the conjunction. 58 //@{ 59 bool test_empty_up_to_date() const; 60 void reset_empty_up_to_date(); 61 void set_empty_up_to_date(); 62 63 bool test_empty() const; 64 void reset_empty(); 65 void set_empty(); 66 67 bool test_universe() const; 68 void reset_universe(); 69 void set_universe(); 70 //@} 71 72 //! Checks if all the invariants are satisfied. 73 bool OK() const; 74 75 PPL_OUTPUT_DECLARATIONS 76 77 /*! \brief 78 Loads from \p s an ASCII representation (as produced by 79 ascii_dump(std::ostream&) const) and sets \p *this accordingly. 80 Returns <CODE>true</CODE> if successful, <CODE>false</CODE> otherwise. 81 */ 82 bool ascii_load(std::istream& s); 83 84 private: 85 //! Status is implemented by means of a finite bitset. 86 typedef unsigned int flags_t; 87 88 //! \name Bit-masks for the individual assertions. 89 //@{ 90 static const flags_t NONE = 0U; 91 static const flags_t EMPTY_UP_TO_DATE = 1U << 0; 92 static const flags_t EMPTY = 1U << 1; 93 static const flags_t UNIVERSE = 1U << 2; 94 //@} 95 96 //! This holds the current bitset. 97 flags_t flags; 98 99 //! Construct from a bit-mask. 100 Status(flags_t mask); 101 102 //! Check whether <EM>all</EM> bits in \p mask are set. 103 bool test_all(flags_t mask) const; 104 105 //! Check whether <EM>at least one</EM> bit in \p mask is set. 106 bool test_any(flags_t mask) const; 107 108 //! Set the bits in \p mask. 109 void set(flags_t mask); 110 111 //! Reset the bits in \p mask. 112 void reset(flags_t mask); 113 }; 114 115 #endif // !defined(PPL_Box_Status_idefs_hh) 116