PPL  0.12.1
Ask_Tell.defs.hh
Go to the documentation of this file.
00001 /* Ask_Tell 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_Ask_Tell_defs_hh
00025 #define PPL_Ask_Tell_defs_hh
00026 
00027 #include "Ask_Tell.types.hh"
00028 #include "iterator_to_const.defs.hh"
00029 #include "globals.types.hh"
00030 #include <iosfwd>
00031 #include <list>
00032 
00033 namespace Parma_Polyhedra_Library {
00034 
00036 
00037 template <typename D>
00038 void swap(Ask_Tell<D>& x, Ask_Tell<D>& y);
00039 
00041 
00042 template <typename D>
00043 bool
00044 operator==(const Ask_Tell<D>& x, const Ask_Tell<D>& y);
00045 
00047 
00048 template <typename D>
00049 bool
00050 operator!=(const Ask_Tell<D>& x, const Ask_Tell<D>& y);
00051 
00052 namespace IO_Operators {
00053 
00055 
00056 template <typename D>
00057 std::ostream&
00058 operator<<(std::ostream&, const Ask_Tell<D>&);
00059 
00060 } // namespace IO_Operators
00061 
00062 } // namespace Parma_Polyhedra_Library
00063 
00065 
00066 template <typename D>
00067 class Parma_Polyhedra_Library::Ask_Tell_Pair {
00068 public:
00070   Ask_Tell_Pair(const D& ask, const D& tell);
00071 
00073   const D& ask() const;
00074 
00076   D& ask();
00077 
00079   const D& tell() const;
00080 
00082   D& tell();
00083 
00090   bool definitely_entails(const Ask_Tell_Pair& y) const;
00091 
00092 private:
00094   D a;
00095 
00097   D t;
00098 };
00099 
00101 
00105 template <typename D>
00106 class Parma_Polyhedra_Library::Ask_Tell {
00107 public:
00109 
00110 
00115   Ask_Tell();
00116 
00118   Ask_Tell(const Ask_Tell& y);
00119 
00124   explicit Ask_Tell(const Ask_Tell_Pair<D>& p);
00125 
00131   Ask_Tell(const D& ask, const D& tell);
00132 
00134   ~Ask_Tell();
00135 
00137 
00139 
00140 
00147   bool definitely_entails(const Ask_Tell& y) const;
00148 
00154   bool is_top() const;
00155 
00161   bool is_bottom() const;
00162 
00167   memory_size_type total_memory_in_bytes() const;
00168 
00173   memory_size_type external_memory_in_bytes() const;
00174 
00181   int32_t hash_code() const;
00182 
00184   bool OK() const;
00185 
00187 
00188 protected:
00190   typedef Ask_Tell_Pair<D> Pair;
00191 
00193 
00197   typedef std::list<Ask_Tell_Pair<D> > Sequence;
00198 
00200   typedef typename Sequence::iterator Sequence_iterator;
00201 
00203   typedef typename Sequence::const_iterator Sequence_const_iterator;
00204 
00206   Sequence sequence;
00207 
00209   mutable bool normalized;
00210 
00211 public:
00212   // Sequence manipulation types, accessors and modifiers
00213   typedef typename Sequence::size_type size_type;
00214   typedef typename Sequence::value_type value_type;
00215 
00226   typedef iterator_to_const<Sequence> iterator;
00227 
00229   typedef const_iterator_to_const<Sequence> const_iterator;
00230 
00232   typedef std::reverse_iterator<iterator> reverse_iterator;
00233 
00235   typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00236 
00238 
00239 
00247   void normalize() const;
00248 
00250   size_type size() const;
00251 
00253   bool empty() const;
00254 
00259   iterator begin();
00260 
00262   iterator end();
00263 
00268   const_iterator begin() const;
00269 
00271   const_iterator end() const;
00272 
00277   reverse_iterator rbegin();
00278 
00280   reverse_iterator rend();
00281 
00287   const_reverse_iterator rbegin() const;
00288 
00290   const_reverse_iterator rend() const;
00291 
00293   Ask_Tell& add_pair(const Ask_Tell_Pair<D>& p);
00294 
00296   Ask_Tell& add_pair(const D& ask, const D& tell);
00297 
00302   iterator drop_pair(iterator position);
00303 
00305   void drop_pairs(iterator first, iterator last);
00306 
00308   void clear();
00309 
00311 
00313 
00314 
00319   Ask_Tell& operator=(const Ask_Tell& y);
00320 
00322   void m_swap(Ask_Tell& y);
00323 
00325   void upper_bound_assign(const Ask_Tell& y);
00326 
00328   void meet_assign(const Ask_Tell& y);
00329 
00331 
00332 protected:
00334   bool is_normalized() const;
00335 
00336   void pair_insert(const D& a, const D& t);
00337   void pair_insert_good(const D& a, const D& t);
00338 
00339   /*
00340     Postcondition:
00341     the map is well formed and there are no two pairs x and y such that
00342     x.ASK.definitely_entails(y.ASK) && y.TELL.definitely_entails(x.TELL).
00343   */
00344   bool reduce();
00345 
00346   // Preconditions:
00347   //
00348   //     the map is well formed and the postcondition of reduce() is satisfied.
00349   //
00350   // Postconditions:
00351   //
00352   //     the map is well formed, the postcondition of reduce() is satisfied,
00353   //     and...
00354   //
00355   bool deduce();
00356 
00357   bool absorb();
00358 
00359   void deabsorb() const;
00360 
00365   bool check_normalized() const;
00366 
00367 protected:
00368   bool probe(const D& tellv, const D& askv) const;
00369 };
00370 
00371 #include "Ask_Tell.inlines.hh"
00372 #include "Ask_Tell.templates.hh"
00373 
00374 #endif // !defined(PPL_Ask_Tell_defs_hh)