PPL  1.2
Parma_Polyhedra_Library::BD_Shape< T >::Status Class Reference

A conjunctive assertion about a BD_Shape<T> object. More...

Public Member Functions

 Status ()
 By default Status is the zero-dim universe assertion. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this. More...
 
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this. More...
 
void print () const
 Prints *this to std::cerr using operator<<. More...
 
bool ascii_load (std::istream &s)
 Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. More...
 
Test, remove or add an individual assertion from the conjunction.
bool test_zero_dim_univ () const
 
void reset_zero_dim_univ ()
 
void set_zero_dim_univ ()
 
bool test_empty () const
 
void reset_empty ()
 
void set_empty ()
 
bool test_shortest_path_closed () const
 
void reset_shortest_path_closed ()
 
void set_shortest_path_closed ()
 
bool test_shortest_path_reduced () const
 
void reset_shortest_path_reduced ()
 
void set_shortest_path_reduced ()
 

Private Types

typedef unsigned int flags_t
 Status is implemented by means of a finite bitset. More...
 

Private Member Functions

 Status (flags_t mask)
 Construct from a bit-mask. More...
 
bool test_all (flags_t mask) const
 Check whether all bits in mask are set. More...
 
bool test_any (flags_t mask) const
 Check whether at least one bit in mask is set. More...
 
void set (flags_t mask)
 Set the bits in mask. More...
 
void reset (flags_t mask)
 Reset the bits in mask. More...
 

Private Attributes

flags_t flags
 This holds the current bitset. More...
 

Static Private Attributes

Bit-masks for the individual assertions.
static const flags_t ZERO_DIM_UNIV = 0U
 
static const flags_t EMPTY = 1U << 0
 
static const flags_t SHORTEST_PATH_CLOSED = 1U << 1
 
static const flags_t SHORTEST_PATH_REDUCED = 1U << 2
 

Related Functions

(Note that these are not member functions.)

bool get_field (std::istream &s, const char *keyword, bool &positive)
 

Detailed Description

template<typename T>
class Parma_Polyhedra_Library::BD_Shape< T >::Status

A conjunctive assertion about a BD_Shape<T> object.

The assertions supported are:

  • zero-dim universe: the BDS is the zero-dimensional vector space $\Rset^0 = \{\cdot\}$;
  • empty: the BDS is the empty set;
  • shortest-path closed: the BDS is represented by a shortest-path closed system of bounded differences, so that all the constraints are as tight as possible;
  • shortest-path reduced: the BDS is represented by a shortest-path closed system of bounded differences and each constraint in such a system is marked as being either redundant or non-redundant.

Not all the conjunctions of these elementary assertions constitute a legal Status. In fact:

  • zero-dim universe excludes any other assertion;
  • empty: excludes any other assertion;
  • shortest-path reduced implies shortest-path closed.

Definition at line 51 of file BD_Shape_defs.hh.

Member Typedef Documentation

template<typename T>
typedef unsigned int Parma_Polyhedra_Library::BD_Shape< T >::Status::flags_t
private

Status is implemented by means of a finite bitset.

Definition at line 89 of file BD_Shape_defs.hh.

Constructor & Destructor Documentation

template<typename T >
Parma_Polyhedra_Library::BD_Shape< T >::Status::Status ( )
inline

By default Status is the zero-dim universe assertion.

Definition at line 37 of file BDS_Status_inlines.hh.

38  : flags(ZERO_DIM_UNIV) {
39 }
flags_t flags
This holds the current bitset.
template<typename T >
Parma_Polyhedra_Library::BD_Shape< T >::Status::Status ( flags_t  mask)
inlineprivate

Construct from a bit-mask.

Definition at line 31 of file BDS_Status_inlines.hh.

32  : flags(mask) {
33 }
flags_t flags
This holds the current bitset.

Member Function Documentation

template<typename T>
void Parma_Polyhedra_Library::BD_Shape< T >::Status::ascii_dump ( ) const

Writes to std::cerr an ASCII representation of *this.

template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::ascii_dump ( std::ostream &  s) const

Writes to s an ASCII representation of *this.

Definition at line 225 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::empty, Parma_Polyhedra_Library::Implementation::BD_Shapes::no, Parma_Polyhedra_Library::Implementation::BD_Shapes::separator, Parma_Polyhedra_Library::Implementation::BD_Shapes::sp_closed, Parma_Polyhedra_Library::Implementation::BD_Shapes::sp_reduced, Parma_Polyhedra_Library::Implementation::BD_Shapes::yes, and Parma_Polyhedra_Library::Implementation::BD_Shapes::zero_dim_univ.

225  {
226  using namespace Implementation::BD_Shapes;
227  s << (test_zero_dim_univ() ? yes : no) << zero_dim_univ << separator
228  << (test_empty() ? yes : no) << empty << separator
229  << separator
232 }
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::ascii_load ( std::istream &  s)

Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise.

Definition at line 238 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::empty, Parma_Polyhedra_Library::BD_Shape< T >::OK(), PPL_UNINITIALIZED, Parma_Polyhedra_Library::BD_Shape< T >::reset_shortest_path_closed(), Parma_Polyhedra_Library::BD_Shape< T >::reset_shortest_path_reduced(), Parma_Polyhedra_Library::BD_Shape< T >::set_empty(), Parma_Polyhedra_Library::BD_Shape< T >::set_shortest_path_closed(), Parma_Polyhedra_Library::BD_Shape< T >::set_shortest_path_reduced(), Parma_Polyhedra_Library::BD_Shape< T >::set_zero_dim_univ(), Parma_Polyhedra_Library::Implementation::BD_Shapes::sp_closed, Parma_Polyhedra_Library::Implementation::BD_Shapes::sp_reduced, and Parma_Polyhedra_Library::Implementation::BD_Shapes::zero_dim_univ.

238  {
239  using namespace Implementation::BD_Shapes;
240  PPL_UNINITIALIZED(bool, positive);
241 
242  if (!get_field(s, zero_dim_univ, positive)) {
243  return false;
244  }
245  if (positive) {
247  }
248 
249  if (!get_field(s, empty, positive)) {
250  return false;
251  }
252  if (positive) {
253  set_empty();
254  }
255 
256  if (!get_field(s, sp_closed, positive)) {
257  return false;
258  }
259  if (positive) {
261  }
262  else {
264  }
265 
266  if (!get_field(s, sp_reduced, positive)) {
267  return false;
268  }
269  if (positive) {
271  }
272  else {
274  }
275 
276  // Check invariants.
277  PPL_ASSERT(OK());
278  return true;
279 }
bool get_field(std::istream &s, const char *keyword, bool &positive)
bool OK() const
Checks if all the invariants are satisfied.
#define PPL_UNINITIALIZED(type, name)
Definition: compiler.hh:72
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 146 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::BD_Shape< T >::Status::reset_empty(), and Parma_Polyhedra_Library::BD_Shape< T >::Status::test_zero_dim_univ().

146  {
147  if (test_zero_dim_univ()) {
148  // Zero-dim universe is OK.
149  return true;
150  }
151 
152  if (test_empty()) {
153  Status copy = *this;
154  copy.reset_empty();
155  if (copy.test_zero_dim_univ()) {
156  return true;
157  }
158  else {
159 #ifndef NDEBUG
160  std::cerr << "The empty flag is incompatible with any other one."
161  << std::endl;
162 #endif
163  return false;
164  }
165  }
166 
167  // Shortest-path reduction implies shortest-path closure.
170  return true;
171  }
172  else {
173 #ifndef NDEBUG
174  std::cerr << "The shortest-path reduction flag should also imply "
175  << "the closure flag."
176  << std::endl;
177 #endif
178  return false;
179  }
180  }
181 
182  // Any other case is OK.
183  return true;
184 }
Status()
By default Status is the zero-dim universe assertion.
template<typename T>
void Parma_Polyhedra_Library::BD_Shape< T >::Status::print ( ) const

Prints *this to std::cerr using operator<<.

template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::reset ( flags_t  mask)
inlineprivate

Reset the bits in mask.

Definition at line 61 of file BDS_Status_inlines.hh.

61  {
62  flags &= ~mask;
63 }
flags_t flags
This holds the current bitset.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::reset_empty ( )
inline

Definition at line 96 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

Referenced by Parma_Polyhedra_Library::BD_Shape< T >::Status::OK().

96  {
97  reset(EMPTY);
98 }
void reset(flags_t mask)
Reset the bits in mask.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::reset_shortest_path_closed ( )
inline

Definition at line 114 of file BDS_Status_inlines.hh.

114  {
115  // A system is reduced only if it is also closed.
117 }
void reset(flags_t mask)
Reset the bits in mask.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::reset_shortest_path_reduced ( )
inline

Definition at line 133 of file BDS_Status_inlines.hh.

133  {
135 }
void reset(flags_t mask)
Reset the bits in mask.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::reset_zero_dim_univ ( )
inline

Definition at line 73 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

73  {
74  // This is a no-op if the current status is not zero-dim.
75  if (flags == ZERO_DIM_UNIV) {
76  // In the zero-dim space, if it is not the universe it is empty.
77  flags = EMPTY;
78  }
79 }
flags_t flags
This holds the current bitset.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::set ( flags_t  mask)
inlineprivate

Set the bits in mask.

Definition at line 55 of file BDS_Status_inlines.hh.

55  {
56  flags |= mask;
57 }
flags_t flags
This holds the current bitset.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::set_empty ( )
inline

Definition at line 102 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

102  {
103  flags = EMPTY;
104 }
flags_t flags
This holds the current bitset.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::set_shortest_path_closed ( )
inline

Definition at line 121 of file BDS_Status_inlines.hh.

121  {
123 }
void set(flags_t mask)
Set the bits in mask.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::set_shortest_path_reduced ( )
inline

Definition at line 139 of file BDS_Status_inlines.hh.

139  {
140  PPL_ASSERT(test_shortest_path_closed());
142 }
void set(flags_t mask)
Set the bits in mask.
template<typename T >
void Parma_Polyhedra_Library::BD_Shape< T >::Status::set_zero_dim_univ ( )
inline

Definition at line 83 of file BDS_Status_inlines.hh.

83  {
84  // Zero-dim universe is incompatible with anything else.
86 }
flags_t flags
This holds the current bitset.
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::test_all ( flags_t  mask) const
inlineprivate

Check whether all bits in mask are set.

Definition at line 43 of file BDS_Status_inlines.hh.

43  {
44  return (flags & mask) == mask;
45 }
flags_t flags
This holds the current bitset.
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::test_any ( flags_t  mask) const
inlineprivate

Check whether at least one bit in mask is set.

Definition at line 49 of file BDS_Status_inlines.hh.

49  {
50  return (flags & mask) != 0;
51 }
flags_t flags
This holds the current bitset.
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::test_empty ( ) const
inline

Definition at line 90 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

90  {
91  return test_any(EMPTY);
92 }
bool test_any(flags_t mask) const
Check whether at least one bit in mask is set.
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::test_shortest_path_closed ( ) const
inline

Definition at line 108 of file BDS_Status_inlines.hh.

108  {
110 }
bool test_any(flags_t mask) const
Check whether at least one bit in mask is set.
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::test_shortest_path_reduced ( ) const
inline

Definition at line 127 of file BDS_Status_inlines.hh.

127  {
129 }
bool test_any(flags_t mask) const
Check whether at least one bit in mask is set.
template<typename T >
bool Parma_Polyhedra_Library::BD_Shape< T >::Status::test_zero_dim_univ ( ) const
inline

Definition at line 67 of file BDS_Status_inlines.hh.

Referenced by Parma_Polyhedra_Library::BD_Shape< T >::Status::OK().

67  {
68  return flags == ZERO_DIM_UNIV;
69 }
flags_t flags
This holds the current bitset.

Friends And Related Function Documentation

template<typename T>
bool get_field ( std::istream &  s,
const char *  keyword,
bool &  positive 
)
related

Reads a keyword and its associated on/off flag from s. Returns true if the operation is successful, returns false otherwise. When successful, positive is set to true if the flag is on; it is set to false otherwise.

Definition at line 208 of file BDS_Status_inlines.hh.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::yes.

Referenced by Parma_Polyhedra_Library::Grid::Status::ascii_load(), and Parma_Polyhedra_Library::Polyhedron::Status::ascii_load().

208  {
209  std::string str;
210  if (!(s >> str)
211  || (str[0] != yes && str[0] != no)
212  || str.substr(1) != keyword) {
213  return false;
214  }
215  positive = (str[0] == yes);
216  return true;
217 }

Member Data Documentation

template<typename T>
const flags_t Parma_Polyhedra_Library::BD_Shape< T >::Status::EMPTY = 1U << 0
staticprivate

Definition at line 94 of file BD_Shape_defs.hh.

template<typename T>
flags_t Parma_Polyhedra_Library::BD_Shape< T >::Status::flags
private

This holds the current bitset.

Definition at line 100 of file BD_Shape_defs.hh.

template<typename T>
const flags_t Parma_Polyhedra_Library::BD_Shape< T >::Status::SHORTEST_PATH_CLOSED = 1U << 1
staticprivate

Definition at line 95 of file BD_Shape_defs.hh.

template<typename T>
const flags_t Parma_Polyhedra_Library::BD_Shape< T >::Status::SHORTEST_PATH_REDUCED = 1U << 2
staticprivate

Definition at line 96 of file BD_Shape_defs.hh.

template<typename T>
const flags_t Parma_Polyhedra_Library::BD_Shape< T >::Status::ZERO_DIM_UNIV = 0U
staticprivate

Definition at line 93 of file BD_Shape_defs.hh.


The documentation for this class was generated from the following files: