PPL  0.12.1
Parma_Polyhedra_Library::Linear_Row::Flags Class Reference

The type of the object to which the coefficients refer to, encoding both topology and kind. More...

#include <Linear_Row.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Linear_Row::Flags:
Collaboration diagram for Parma_Polyhedra_Library::Linear_Row::Flags:

List of all members.

Public Member Functions

 Flags ()
 Default constructor: builds an object where all flags are invalid.
 Flags (Topology t)
 Builds an object corresponding to the topology t.
 Flags (Topology t, Kind k)
 Builds an object corresponding to the topology t and kind k.
bool operator== (const Flags &y) const
 Returns true if and only if *this and y are equal.
bool operator!= (const Flags &y) const
 Returns true if and only if *this and y are different.
void ascii_dump () const
 Writes to std::cerr an ASCII representation of *this.
void ascii_dump (std::ostream &s) const
 Writes to s an ASCII representation of *this.
void print () const
 Prints *this to std::cerr using operator<<.
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.
Testing and setting the type
Topology topology () const
bool is_necessarily_closed () const
bool is_not_necessarily_closed () const
bool is_line_or_equality () const
bool is_ray_or_point_or_inequality () const
void set_necessarily_closed ()
void set_not_necessarily_closed ()
void set_is_line_or_equality ()
void set_is_ray_or_point_or_inequality ()

Static Protected Attributes

static const unsigned first_free_bit = Dense_Row::Flags::first_free_bit + 4
 Index of the first bit derived classes can use.

Private Member Functions

 Flags (base_type mask)
 Builds the type from a bit-mask.
 Flags (Dense_Row::Flags flags)
 Constructor from a Dense_Row::Flags object.

Static Private Attributes

The bits that are currently in use
static const unsigned rpi_validity_bit = Dense_Row::Flags::first_free_bit + 0
static const unsigned rpi_bit = Dense_Row::Flags::first_free_bit + 1
static const unsigned nnc_validity_bit = Dense_Row::Flags::first_free_bit + 2
static const unsigned nnc_bit = Dense_Row::Flags::first_free_bit + 3

Friends

class Parma_Polyhedra_Library::Linear_Row

Detailed Description

The type of the object to which the coefficients refer to, encoding both topology and kind.

This combines the information about the topology (necessarily closed or not) and the kind (line/equality or ray/point/inequality) of a Linear_Row object.

Definition at line 144 of file Linear_Row.defs.hh.


Constructor & Destructor Documentation

Default constructor: builds an object where all flags are invalid.

Definition at line 34 of file Linear_Row.inlines.hh.

  : Dense_Row::Flags() {
  // Note that the constructed type has its validity bit unset.
}

Builds an object corresponding to the topology t.

Definition at line 45 of file Linear_Row.inlines.hh.

References nnc_validity_bit, and Parma_Polyhedra_Library::Row_Flags::set_bits().

  : Dense_Row::Flags(static_cast<unsigned>(t) << nnc_bit) {
#ifndef NDEBUG
  set_bits(1U << nnc_validity_bit);
#endif
}

Builds an object corresponding to the topology t and kind k.

Definition at line 53 of file Linear_Row.inlines.hh.

References nnc_validity_bit, rpi_validity_bit, and Parma_Polyhedra_Library::Row_Flags::set_bits().

  : Dense_Row::Flags((static_cast<unsigned>(k) << rpi_bit)
                     | (static_cast<unsigned>(t) << nnc_bit)) {
#ifndef NDEBUG
  set_bits((1U << rpi_validity_bit) | (1U << nnc_validity_bit));
#endif
}

Builds the type from a bit-mask.

Constructor from a Dense_Row::Flags object.

Definition at line 40 of file Linear_Row.inlines.hh.


Member Function Documentation

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

Reimplemented from Parma_Polyhedra_Library::Row_Flags.

Writes to s an ASCII representation of *this.

Reimplemented from Parma_Polyhedra_Library::Row_Flags.

Definition at line 155 of file Linear_Row.cc.

                                                  {
  bool is_rpi = test_bits(1U << Flags::rpi_bit);
  bool is_nnc = test_bits(1U << Flags::nnc_bit);
  bool rpi_valid;
  bool nnc_valid;
#ifdef NDEBUG
  // Dump unhandled bits always as true so to permit loading from a
  // debug enabled executable without failing assertions.
  rpi_valid = true;
  nnc_valid = true;
#else
  rpi_valid = test_bits(1U << Flags::rpi_validity_bit);
  nnc_valid = test_bits(1U << Flags::nnc_validity_bit);
#endif
  s << (rpi_valid ? '+' : '-') << rpi_valid_text << ' '
    << (is_rpi ? '+' : '-') << is_rpi_text << ' '
    << ' '
    << (nnc_valid ? '+' : '-') << nnc_valid_text << ' '
    << (is_nnc ? '+' : '-') << is_nnc_text;
}

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

Reimplemented from Parma_Polyhedra_Library::Row_Flags.

Definition at line 179 of file Linear_Row.cc.

References Parma_Polyhedra_Library::Row_Flags::first_free_bit, Parma_Polyhedra_Library::Interval_NS::reset_bits(), and Parma_Polyhedra_Library::Interval_NS::set_bits().

Referenced by Parma_Polyhedra_Library::Linear_Row::ascii_load().

                                            {
  std::string str;
  // Assume that the bits are used in sequence.
  reset_bits(std::numeric_limits<base_type>::max());
  for (unsigned int bit = 0;
       bit < (sizeof(bit_texts) / sizeof(char*));
       ++bit) {
    if (!(s >> str))
      return false;
    if (str[0] == '+') {
      bool load = true;
#ifdef NDEBUG
      // Do not load unhandled bits.
      if (bit == rpi_validity_bit || bit == nnc_validity_bit)
        load = false;
#endif
      if (load)
        set_bits(1U << (Dense_Row::Flags::first_free_bit + bit));
    }
    else if (str[0] != '-')
      return false;
    if (str.compare(1, strlen(bit_texts[bit]), bit_texts[bit]) != 0)
      return false;
  }
  return true;
}

Definition at line 93 of file Linear_Row.inlines.hh.

References Parma_Polyhedra_Library::NOT_NECESSARILY_CLOSED, and PPL_ASSERT.

                                                 {
  PPL_ASSERT(test_bits(1U << nnc_validity_bit)
             && ("nnc bit tested before being initialized" != 0));
  return test_bits(static_cast<unsigned>(NOT_NECESSARILY_CLOSED) << nnc_bit);
}
bool Parma_Polyhedra_Library::Linear_Row::Flags::operator!= ( const Flags y) const
inline

Returns true if and only if *this and y are different.

Definition at line 134 of file Linear_Row.inlines.hh.

References Parma_Polyhedra_Library::Linear_Row::operator==().

                                                {
  return !operator==(y);
}
bool Parma_Polyhedra_Library::Linear_Row::Flags::operator== ( const Flags y) const
inline

Returns true if and only if *this and y are equal.

Definition at line 128 of file Linear_Row.inlines.hh.

References Parma_Polyhedra_Library::Row_Flags::get_bits(), and Parma_Polyhedra_Library::Interval_NS::get_bits().

                                                {
  base_type mask = low_bits_mask<base_type>(first_free_bit);
  return (get_bits() & mask) == (y.get_bits() & mask);
}

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

Reimplemented from Parma_Polyhedra_Library::Row_Flags.


Friends And Related Function Documentation

Definition at line 212 of file Linear_Row.defs.hh.


Member Data Documentation

Index of the first bit derived classes can use.

Reimplemented from Parma_Polyhedra_Library::Row_Flags.

Definition at line 210 of file Linear_Row.defs.hh.

Definition at line 202 of file Linear_Row.defs.hh.

Referenced by Flags().

Definition at line 198 of file Linear_Row.defs.hh.

Referenced by Flags().


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