1 /* Octagonal_Shape<T>::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_Og_Status_idefs_hh 25 #define PPL_Og_Status_idefs_hh 1 26 27 #ifndef PPL_IN_Octagonal_Shape_CLASS 28 #error "Do not include Og_Status_idefs.hh directly; use Octagonal_Shape_defs.hh instead" 29 #endif 30 31 //! A conjunctive assertion about a Octagonal_Shape<T> object. 32 /*! 33 The assertions supported are: 34 - <EM>zero-dim universe</EM>: the polyhedron is the zero-dimensional 35 vector space \f$\Rset^0 = \{\cdot\}\f$; 36 - <EM>empty</EM>: the polyhedron is the empty set; 37 - <EM>strongly closed</EM>: the Octagonal_Shape object is strongly 38 closed, so that all the constraints are as tight as possible. 39 40 Not all the conjunctions of these elementary assertions constitute 41 a legal Status. In fact: 42 - <EM>zero-dim universe</EM> excludes any other assertion; 43 - <EM>empty</EM>: excludes any other assertion. 44 */ 45 class Status { 46 public: 47 //! By default Status is the <EM>zero-dim universe</EM> assertion. 48 Status(); 49 50 //! \name Test, remove or add an individual assertion from the conjunction. 51 //@{ 52 bool test_zero_dim_univ() const; 53 void reset_zero_dim_univ(); 54 void set_zero_dim_univ(); 55 56 bool test_empty() const; 57 void reset_empty(); 58 void set_empty(); 59 60 bool test_strongly_closed() const; 61 void reset_strongly_closed(); 62 void set_strongly_closed(); 63 //@} 64 65 //! Checks if all the invariants are satisfied. 66 bool OK() const; 67 68 /*! \brief 69 Writes to \p s an ASCII representation of the internal 70 representation of \p *this. 71 */ 72 void ascii_dump(std::ostream& s) const; 73 74 /*! \brief 75 Loads from \p s an ASCII representation (as produced by 76 ascii_dump(std::ostream&) const) and sets \p *this accordingly. 77 Returns <CODE>true</CODE> if successful, <CODE>false</CODE> otherwise. 78 */ 79 bool ascii_load(std::istream& s); 80 81 private: 82 //! Status is implemented by means of a finite bitset. 83 typedef unsigned int flags_t; 84 85 //! \name Bitmasks for the individual assertions. 86 //@{ 87 static const flags_t ZERO_DIM_UNIV = 0U; 88 static const flags_t EMPTY = 1U << 0; 89 static const flags_t STRONGLY_CLOSED = 1U << 1; 90 //@} 91 92 //! This holds the current bitset. 93 flags_t flags; 94 95 //! Construct from a bitmask. 96 Status(flags_t mask); 97 98 //! Check whether <EM>all</EM> bits in \p mask are set. 99 bool test_all(flags_t mask) const; 100 101 //! Check whether <EM>at least one</EM> bit in \p mask is set. 102 bool test_any(flags_t mask) const; 103 104 //! Set the bits in \p mask. 105 void set(flags_t mask); 106 107 //! Reset the bits in \p mask. 108 void reset(flags_t mask); 109 110 }; 111 112 #endif // !defined(PPL_Og_Status_idefs_hh) 113