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