PPL  0.12.1
Constraint_System.defs.hh
Go to the documentation of this file.
00001 /* Constraint_System class declaration.
00002    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
00003    Copyright (C) 2010-2012 BUGSENG srl (http://bugseng.com)
00004 
00005 This file is part of the Parma Polyhedra Library (PPL).
00006 
00007 The PPL is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 The PPL is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software Foundation,
00019 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
00020 
00021 For the most up-to-date information see the Parma Polyhedra Library
00022 site: http://bugseng.com/products/ppl/ . */
00023 
00024 #ifndef PPL_Constraint_System_defs_hh
00025 #define PPL_Constraint_System_defs_hh 1
00026 
00027 #include "Constraint_System.types.hh"
00028 #include "Linear_Expression.types.hh"
00029 #include "Linear_System.defs.hh"
00030 #include "Generator.types.hh"
00031 #include "Polyhedron.types.hh"
00032 #include "Constraint.types.hh"
00033 #include "Congruence_System.types.hh"
00034 #include <iterator>
00035 #include <iosfwd>
00036 
00037 namespace Parma_Polyhedra_Library {
00038 
00039 namespace IO_Operators {
00040 
00042 
00047 std::ostream& operator<<(std::ostream& s, const Constraint_System& cs);
00048 
00049 } // namespace IO_Operators
00050 
00052 
00053 void swap(Constraint_System& x, Constraint_System& y);
00054 
00055 // Put it in the namespace here to declare it friend later.
00057 bool operator==(const Polyhedron& x, const Polyhedron& y);
00058 
00059 } // namespace Parma_Polyhedra_Library
00060 
00062 
00122 class Parma_Polyhedra_Library::Constraint_System : private Linear_System {
00123 public:
00125   Constraint_System();
00126 
00128   explicit Constraint_System(const Constraint& c);
00129 
00131   explicit Constraint_System(const Congruence_System& cgs);
00132 
00134   Constraint_System(const Constraint_System& cs);
00135 
00137   ~Constraint_System();
00138 
00140   Constraint_System& operator=(const Constraint_System& y);
00141 
00143   static dimension_type max_space_dimension();
00144 
00146   dimension_type space_dimension() const;
00147 
00152   bool has_equalities() const;
00153 
00158   bool has_strict_inequalities() const;
00159 
00164   void clear();
00165 
00170   void insert(const Constraint& c);
00171 
00173   static void initialize();
00174 
00176   static void finalize();
00177 
00181   static const Constraint_System& zero_dim_empty();
00182 
00184 
00198   class const_iterator
00199     : public std::iterator<std::forward_iterator_tag,
00200                            Constraint,
00201                            ptrdiff_t,
00202                            const Constraint*,
00203                            const Constraint&> {
00204   public:
00206     const_iterator();
00207 
00209     const_iterator(const const_iterator& y);
00210 
00212     ~const_iterator();
00213 
00215     const_iterator& operator=(const const_iterator& y);
00216 
00218     const Constraint& operator*() const;
00219 
00221     const Constraint* operator->() const;
00222 
00224     const_iterator& operator++();
00225 
00227     const_iterator operator++(int);
00228 
00233     bool operator==(const const_iterator& y) const;
00234 
00239     bool operator!=(const const_iterator& y) const;
00240 
00241   private:
00242     friend class Constraint_System;
00243 
00245     Linear_System::const_iterator i;
00246 
00248     const Linear_System* csp;
00249 
00251     const_iterator(const Linear_System::const_iterator& iter,
00252                    const Constraint_System& cs);
00253 
00255     void skip_forward();
00256   };
00257 
00259   bool empty() const;
00260 
00266   const_iterator begin() const;
00267 
00269   const_iterator end() const;
00270 
00272 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00273 
00277 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00278   bool OK() const;
00279 
00280   PPL_OUTPUT_DECLARATIONS
00281 
00287   bool ascii_load(std::istream& s);
00288 
00290   memory_size_type total_memory_in_bytes() const;
00291 
00293   memory_size_type external_memory_in_bytes() const;
00294 
00296   void m_swap(Constraint_System& y);
00297 
00298 private:
00303   static const Constraint_System* zero_dim_empty_p;
00304 
00305   friend class const_iterator;
00306   friend class Parma_Polyhedra_Library::Polyhedron;
00307 
00308   friend bool operator==(const Polyhedron& x, const Polyhedron& y);
00309 
00311   explicit Constraint_System(Topology topol);
00312 
00318   Constraint_System(Topology topol,
00319                     dimension_type n_rows, dimension_type n_columns);
00320 
00328   bool adjust_topology_and_space_dimension(Topology new_topology,
00329                                            dimension_type new_space_dim);
00330 
00332   Constraint& operator[](dimension_type k);
00333 
00335   const Constraint& operator[](dimension_type k) const;
00336 
00338   bool satisfies_all_constraints(const Generator& g) const;
00339 
00341 
00375   void affine_preimage(dimension_type v,
00376                        const Linear_Expression& expr,
00377                        Coefficient_traits::const_reference denominator);
00378 
00380   dimension_type num_equalities() const;
00381 
00383   dimension_type num_inequalities() const;
00384 
00391   void simplify();
00392 
00398   void insert_pending(const Constraint& c);
00399 
00401   void add_low_level_constraints();
00402 };
00403 
00404 namespace Parma_Polyhedra_Library {
00405 
00406 namespace Implementation {
00407 
00408 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
00409 
00410 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
00411 dimension_type
00412 num_constraints(const Constraint_System& cs);
00413 
00414 } // namespace Implementation
00415 
00416 } // namespace Parma_Polyhedra_Library
00417 
00418 // Constraint_System.inlines.hh is not included here on purpose.
00419 
00420 #endif // !defined(PPL_Constraint_System_defs_hh)