PPL  0.12.1
Parma_Polyhedra_Library::Octagonal_Shape< T >::Status Class Reference

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

List of all members.

Public Member Functions

 Status ()
 By default Status is the zero-dim universe assertion.
bool OK () const
 Checks if all the invariants are satisfied.
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of the internal representation of *this.
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.
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_strongly_closed () const
void reset_strongly_closed ()
void set_strongly_closed ()

Private Types

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

Private Member Functions

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

Private Attributes

flags_t flags
 This holds the current bitset.

Static Private Attributes

Bitmasks for the individual assertions.
static const flags_t ZERO_DIM_UNIV = 0U
static const flags_t EMPTY = 1U << 0
static const flags_t STRONGLY_CLOSED = 1U << 1

Related Functions

(Note that these are not member functions.)

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

Detailed Description

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

A conjunctive assertion about a Octagonal_Shape<T> object.

The assertions supported are:

  • zero-dim universe: the polyhedron is the zero-dimensional vector space $\Rset^0 = \{\cdot\}$;
  • empty: the polyhedron is the empty set;
  • strongly closed: the Octagonal_Shape object is strongly closed, so that all the constraints are as tight as possible.

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.

Definition at line 46 of file Octagonal_Shape.defs.hh.


Member Typedef Documentation

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

Status is implemented by means of a finite bitset.

Definition at line 84 of file Octagonal_Shape.defs.hh.


Constructor & Destructor Documentation

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

By default Status is the zero-dim universe assertion.

Definition at line 37 of file Og_Status.inlines.hh.

template<typename T >
Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::Status ( flags_t  mask)
inlineprivate

Construct from a bitmask.

Definition at line 31 of file Og_Status.inlines.hh.

  : flags(mask) {
}

Member Function Documentation

template<typename T >
bool Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::ascii_load ( std::istream &  s)
inline
template<typename T >
bool Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::OK ( ) const
inline

Checks if all the invariants are satisfied.

Definition at line 125 of file Og_Status.inlines.hh.

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

                                   {
  if (test_zero_dim_univ())
    // Zero-dim universe is OK.
    return true;

  if (test_empty()) {
    Status copy = *this;
    copy.reset_empty();
    if (copy.test_zero_dim_univ())
      return true;
    else {
#ifndef NDEBUG
      std::cerr << "The empty flag is incompatible with any other one."
                << std::endl;
#endif
      return false;
    }
  }

  // Any other case is OK.
  return true;
}
template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::reset ( flags_t  mask)
inlineprivate

Reset the bits in mask.

Definition at line 61 of file Og_Status.inlines.hh.

                                            {
  flags &= ~mask;
}
template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::reset_strongly_closed ( )
inline

Definition at line 113 of file Og_Status.inlines.hh.

template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::reset_zero_dim_univ ( )
inline

Definition at line 73 of file Og_Status.inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

                                              {
  // This is a no-op if the current status is not zero-dim.
  if (flags == ZERO_DIM_UNIV)
    // In the zero-dim space, if it is not the universe it is empty.
    flags = EMPTY;
}
template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::set ( flags_t  mask)
inlineprivate

Set the bits in mask.

Definition at line 55 of file Og_Status.inlines.hh.

                                          {
  flags |= mask;
}
template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::set_empty ( )
inline

Definition at line 101 of file Og_Status.inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

                                    {
  flags = EMPTY;
}
template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::set_strongly_closed ( )
inline

Definition at line 119 of file Og_Status.inlines.hh.

                                              {
  set(STRONGLY_CLOSED);
}
template<typename T >
void Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::set_zero_dim_univ ( )
inline

Definition at line 82 of file Og_Status.inlines.hh.

                                            {
  // Zero-dim universe is incompatible with anything else.
  flags = ZERO_DIM_UNIV;
}
template<typename T >
bool Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::test_all ( flags_t  mask) const
inlineprivate

Check whether all bits in mask are set.

Definition at line 43 of file Og_Status.inlines.hh.

                                                     {
  return (flags & mask) == mask;
}
template<typename T >
bool Parma_Polyhedra_Library::Octagonal_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 Og_Status.inlines.hh.

                                                     {
  return (flags & mask) != 0;
}
template<typename T >
bool Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::test_empty ( ) const
inline

Definition at line 89 of file Og_Status.inlines.hh.

References Parma_Polyhedra_Library::EMPTY.

                                           {
  return test_any(EMPTY);
}
template<typename T >
bool Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::test_strongly_closed ( ) const
inline

Definition at line 107 of file Og_Status.inlines.hh.

                                                     {
  return test_any(STRONGLY_CLOSED);
}
template<typename T >
bool Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::test_zero_dim_univ ( ) const
inline

Friends And Related Function Documentation

template<typename T>
bool get_field ( std::istream &  s,
const std::string &  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 168 of file Og_Status.inlines.hh.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::no, and Parma_Polyhedra_Library::Implementation::BD_Shapes::yes.

                                                                   {
  std::string str;
  if (!(s >> str)
      || (str[0] != yes && str[0] != no)
      || str.substr(1) != keyword)
    return false;
  positive = (str[0] == yes);
  return true;
}

Member Data Documentation

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

Definition at line 89 of file Octagonal_Shape.defs.hh.

This holds the current bitset.

Definition at line 94 of file Octagonal_Shape.defs.hh.

template<typename T>
const flags_t Parma_Polyhedra_Library::Octagonal_Shape< T >::Status::STRONGLY_CLOSED = 1U << 1
staticprivate

Definition at line 90 of file Octagonal_Shape.defs.hh.

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

Definition at line 88 of file Octagonal_Shape.defs.hh.


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