1 /* Widening_Function class declaration.
2    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3    Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Widening_Function_defs_hh
25 #define PPL_Widening_Function_defs_hh 1
26 
27 #include "Widening_Function_types.hh"
28 #include "Constraint_System_types.hh"
29 
30 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
31 //! Wraps a widening method into a function object.
32 /*! \ingroup PPL_CXX_interface */
33 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
34 template <typename PSET>
35 class Parma_Polyhedra_Library::Widening_Function {
36 public:
37   //! The (parametric) type of a widening method.
38   typedef void (PSET::* Widening_Method)(const PSET&, unsigned*);
39 
40   //! Explicit unary constructor.
41   explicit
42   Widening_Function(Widening_Method wm);
43 
44   //! Function-application operator.
45   /*!
46     Computes <CODE>(x.*wm)(y, tp)</CODE>, where \p wm is the widening
47     method stored at construction time.
48   */
49   void operator()(PSET& x, const PSET& y, unsigned* tp = 0) const;
50 
51 private:
52   //! The widening method.
53   Widening_Method w_method;
54 };
55 
56 
57 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
58 //! Wraps a limited widening method into a function object.
59 /*! \ingroup PPL_CXX_interface */
60 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
61 template <typename PSET, typename CSYS>
62 class Parma_Polyhedra_Library::Limited_Widening_Function {
63 public:
64   //! The (parametric) type of a limited widening method.
65   typedef void (PSET::* Limited_Widening_Method)(const PSET&,
66                                                  const CSYS&,
67                                                  unsigned*);
68 
69   //! Constructor.
70   /*!
71     \param lwm
72     The limited widening method.
73 
74     \param cs
75     The constraint system limiting the widening.
76   */
77   Limited_Widening_Function(Limited_Widening_Method lwm,
78                             const CSYS& cs);
79 
80   //! Function-application operator.
81   /*!
82     Computes <CODE>(x.*lwm)(y, cs, tp)</CODE>, where \p lwm and \p cs
83     are the limited widening method and the constraint system stored
84     at construction time.
85   */
86   void operator()(PSET& x, const PSET& y, unsigned* tp = 0) const;
87 
88 private:
89   //! The limited widening method.
90   Limited_Widening_Method lw_method;
91   //! A constant reference to the constraint system limiting the widening.
92   const CSYS& limiting_cs;
93 };
94 
95 namespace Parma_Polyhedra_Library {
96 
97 //! Wraps a widening method into a function object.
98 /*!
99   \relates Pointset_Powerset
100 
101   \param wm
102   The widening method.
103 */
104 template <typename PSET>
105 Widening_Function<PSET>
106 widen_fun_ref(void (PSET::* wm)(const PSET&, unsigned*));
107 
108 //! Wraps a limited widening method into a function object.
109 /*!
110   \relates Pointset_Powerset
111 
112   \param lwm
113   The limited widening method.
114 
115   \param cs
116   The constraint system limiting the widening.
117 */
118 template <typename PSET, typename CSYS>
119 Limited_Widening_Function<PSET, CSYS>
120 widen_fun_ref(void (PSET::* lwm)(const PSET&, const CSYS&, unsigned*),
121               const CSYS& cs);
122 
123 } // namespace Parma_Polyhedra_Library
124 
125 #include "Widening_Function_inlines.hh"
126 
127 #endif // !defined(PPL_Widening_Function_defs_hh)
128