PPL  1.2
Parma_Polyhedra_Library::Box< ITV >::Status Class Reference

Public Member Functions

 Status ()
 By default Status is the empty set of assertion. More...
 
 Status (const Status &y)
 Ordinary copy constructor. More...
 
template<typename Other_ITV >
 Status (const typename Box< Other_ITV >::Status &y)
 Copy constructor from a box of different type. 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_empty_up_to_date () const
 
void reset_empty_up_to_date ()
 
void set_empty_up_to_date ()
 
bool test_empty () const
 
void reset_empty ()
 
void set_empty ()
 
bool test_universe () const
 
void reset_universe ()
 
void set_universe ()
 

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 NONE = 0U
 
static const flags_t EMPTY_UP_TO_DATE = 1U << 0
 
static const flags_t EMPTY = 1U << 1
 
static const flags_t UNIVERSE = 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 ITV>
class Parma_Polyhedra_Library::Box< ITV >::Status

Definition at line 46 of file Box_defs.hh.

Member Typedef Documentation

template<typename ITV>
typedef unsigned int Parma_Polyhedra_Library::Box< ITV >::Status::flags_t
private

Status is implemented by means of a finite bitset.

Definition at line 87 of file Box_defs.hh.

Constructor & Destructor Documentation

template<typename ITV >
Parma_Polyhedra_Library::Box< ITV >::Status::Status ( )
inline

By default Status is the empty set of assertion.

Definition at line 52 of file Box_Status_inlines.hh.

53  : flags(NONE) {
54 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
Parma_Polyhedra_Library::Box< ITV >::Status::Status ( const Status y)
inline

Ordinary copy constructor.

Definition at line 39 of file Box_Status_inlines.hh.

40  : flags(y.flags) {
41 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
template<typename Other_ITV >
Parma_Polyhedra_Library::Box< ITV >::Status::Status ( const typename Box< Other_ITV >::Status y)
inline

Copy constructor from a box of different type.

Definition at line 46 of file Box_Status_inlines.hh.

47  : flags(y.flags) {
48 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
Parma_Polyhedra_Library::Box< ITV >::Status::Status ( flags_t  mask)
inlineprivate

Construct from a bit-mask.

Definition at line 33 of file Box_Status_inlines.hh.

34  : flags(mask) {
35 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98

Member Function Documentation

template<typename ITV>
void Parma_Polyhedra_Library::Box< ITV >::Status::ascii_dump ( ) const

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

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

Writes to s an ASCII representation of *this.

Definition at line 190 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::empty, Parma_Polyhedra_Library::Implementation::Boxes::empty_up_to_date, Parma_Polyhedra_Library::Implementation::Boxes::no, Parma_Polyhedra_Library::Implementation::Boxes::separator, Parma_Polyhedra_Library::Implementation::Boxes::universe, and Parma_Polyhedra_Library::Implementation::Boxes::yes.

template<typename ITV >
bool Parma_Polyhedra_Library::Box< ITV >::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 201 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Boxes::empty, Parma_Polyhedra_Library::Implementation::Boxes::empty_up_to_date, Parma_Polyhedra_Library::Box< ITV >::OK(), PPL_UNINITIALIZED, Parma_Polyhedra_Library::Box< ITV >::set_empty(), Parma_Polyhedra_Library::Box< ITV >::set_empty_up_to_date(), and Parma_Polyhedra_Library::Implementation::Boxes::universe.

201  {
202  using namespace Implementation::Boxes;
203  PPL_UNINITIALIZED(bool, positive);
204 
206  return false;
207  }
208  if (positive) {
210  }
211 
212  if (!get_field(s, Implementation::Boxes::empty, positive)) {
213  return false;
214  }
215  if (positive) {
216  set_empty();
217  }
218  if (!get_field(s, universe, positive)) {
219  return false;
220  }
221  if (positive) {
222  set_universe();
223  }
224  else {
225  reset_universe();
226  }
227 
228  // Check invariants.
229  PPL_ASSERT(OK());
230  return true;
231 }
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 ITV >
bool Parma_Polyhedra_Library::Box< ITV >::Status::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 136 of file Box_Status_inlines.hh.

136  {
138  && test_empty()
139  && test_universe()) {
140 #ifndef NDEBUG
141  std::cerr
142  << "The status asserts emptiness and universality at the same time."
143  << std::endl;
144 #endif
145  return false;
146  }
147 
148  // Any other case is OK.
149  return true;
150 }
template<typename ITV>
void Parma_Polyhedra_Library::Box< ITV >::Status::print ( ) const

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

template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::reset ( flags_t  mask)
inlineprivate

Reset the bits in mask.

Definition at line 76 of file Box_Status_inlines.hh.

76  {
77  flags &= ~mask;
78 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::reset_empty ( )
inline

Definition at line 106 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

106  {
107  reset(EMPTY);
108 }
void reset(flags_t mask)
Reset the bits in mask.
static const flags_t EMPTY
Definition: Box_defs.hh:93
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::reset_empty_up_to_date ( )
inline

Definition at line 88 of file Box_Status_inlines.hh.

88  {
90 }
static const flags_t EMPTY_UP_TO_DATE
Definition: Box_defs.hh:92
void reset(flags_t mask)
Reset the bits in mask.
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::reset_universe ( )
inline

Definition at line 124 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::UNIVERSE.

124  {
125  reset(UNIVERSE);
126 }
void reset(flags_t mask)
Reset the bits in mask.
static const flags_t UNIVERSE
Definition: Box_defs.hh:94
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::set ( flags_t  mask)
inlineprivate

Set the bits in mask.

Definition at line 70 of file Box_Status_inlines.hh.

70  {
71  flags |= mask;
72 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::set_empty ( )
inline

Definition at line 112 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

112  {
113  set(EMPTY);
114 }
void set(flags_t mask)
Set the bits in mask.
static const flags_t EMPTY
Definition: Box_defs.hh:93
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::set_empty_up_to_date ( )
inline

Definition at line 94 of file Box_Status_inlines.hh.

94  {
96 }
void set(flags_t mask)
Set the bits in mask.
static const flags_t EMPTY_UP_TO_DATE
Definition: Box_defs.hh:92
template<typename ITV >
void Parma_Polyhedra_Library::Box< ITV >::Status::set_universe ( )
inline

Definition at line 130 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::UNIVERSE.

130  {
131  set(UNIVERSE);
132 }
void set(flags_t mask)
Set the bits in mask.
static const flags_t UNIVERSE
Definition: Box_defs.hh:94
template<typename ITV >
bool Parma_Polyhedra_Library::Box< ITV >::Status::test_all ( flags_t  mask) const
inlineprivate

Check whether all bits in mask are set.

Definition at line 58 of file Box_Status_inlines.hh.

58  {
59  return (flags & mask) == mask;
60 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
bool Parma_Polyhedra_Library::Box< ITV >::Status::test_any ( flags_t  mask) const
inlineprivate

Check whether at least one bit in mask is set.

Definition at line 64 of file Box_Status_inlines.hh.

64  {
65  return (flags & mask) != 0;
66 }
flags_t flags
This holds the current bitset.
Definition: Box_defs.hh:98
template<typename ITV >
bool Parma_Polyhedra_Library::Box< ITV >::Status::test_empty ( ) const
inline

Definition at line 100 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

100  {
101  return test_any(EMPTY);
102 }
bool test_any(flags_t mask) const
Check whether at least one bit in mask is set.
static const flags_t EMPTY
Definition: Box_defs.hh:93
template<typename ITV >
bool Parma_Polyhedra_Library::Box< ITV >::Status::test_empty_up_to_date ( ) const
inline

Definition at line 82 of file Box_Status_inlines.hh.

Referenced by Parma_Polyhedra_Library::Box< ITV >::concatenate_assign().

82  {
83  return test_any(EMPTY_UP_TO_DATE);
84 }
static const flags_t EMPTY_UP_TO_DATE
Definition: Box_defs.hh:92
bool test_any(flags_t mask) const
Check whether at least one bit in mask is set.
template<typename ITV >
bool Parma_Polyhedra_Library::Box< ITV >::Status::test_universe ( ) const
inline

Definition at line 118 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::UNIVERSE.

118  {
119  return test_any(UNIVERSE);
120 }
bool test_any(flags_t mask) const
Check whether at least one bit in mask is set.
static const flags_t UNIVERSE
Definition: Box_defs.hh:94

Friends And Related Function Documentation

template<typename ITV>
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 173 of file Box_Status_inlines.hh.

References Parma_Polyhedra_Library::Implementation::Boxes::yes.

173  {
174  std::string str;
175  if (!(s >> str)
176  || (str[0] != yes && str[0] != no)
177  || str.substr(1) != keyword) {
178  return false;
179  }
180  positive = (str[0] == yes);
181  return true;
182 }

Member Data Documentation

template<typename ITV>
const flags_t Parma_Polyhedra_Library::Box< ITV >::Status::EMPTY = 1U << 1
staticprivate

Definition at line 93 of file Box_defs.hh.

template<typename ITV>
const flags_t Parma_Polyhedra_Library::Box< ITV >::Status::EMPTY_UP_TO_DATE = 1U << 0
staticprivate

Definition at line 92 of file Box_defs.hh.

template<typename ITV>
flags_t Parma_Polyhedra_Library::Box< ITV >::Status::flags
private

This holds the current bitset.

Definition at line 98 of file Box_defs.hh.

template<typename ITV>
const flags_t Parma_Polyhedra_Library::Box< ITV >::Status::NONE = 0U
staticprivate

Definition at line 91 of file Box_defs.hh.

template<typename ITV>
const flags_t Parma_Polyhedra_Library::Box< ITV >::Status::UNIVERSE = 1U << 2
staticprivate

Definition at line 94 of file Box_defs.hh.


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