1 /* Variable class implementation: inline functions.
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_Variable_inlines_hh
25 #define PPL_Variable_inlines_hh 1
26 
27 #include "globals_defs.hh"
28 #include <stdexcept>
29 
30 namespace Parma_Polyhedra_Library {
31 
32 inline dimension_type
max_space_dimension()33 Variable::max_space_dimension() {
34   return not_a_dimension() - 1;
35 }
36 
37 inline
Variable(dimension_type i)38 Variable::Variable(dimension_type i)
39   : varid((i < max_space_dimension())
40           ? i
41           : (throw std::length_error("PPL::Variable::Variable(i):\n"
42                                      "i exceeds the maximum allowed "
43                                      "variable identifier."), i)) {
44 }
45 
46 inline dimension_type
id() const47 Variable::id() const {
48   return varid;
49 }
50 
51 inline dimension_type
space_dimension() const52 Variable::space_dimension() const {
53   return varid + 1;
54 }
55 
56 inline memory_size_type
external_memory_in_bytes() const57 Variable::external_memory_in_bytes() const {
58   return 0;
59 }
60 
61 inline memory_size_type
total_memory_in_bytes() const62 Variable::total_memory_in_bytes() const {
63   return sizeof(*this) + external_memory_in_bytes();
64 }
65 
66 inline void
set_output_function(output_function_type * p)67 Variable::set_output_function(output_function_type* p) {
68   current_output_function = p;
69 }
70 
71 inline Variable::output_function_type*
get_output_function()72 Variable::get_output_function() {
73   return current_output_function;
74 }
75 
76 /*! \relates Variable */
77 inline bool
less(const Variable v,const Variable w)78 less(const Variable v, const Variable w) {
79   return v.id() < w.id();
80 }
81 
82 inline bool
operator ()(const Variable x,const Variable y) const83 Variable::Compare::operator()(const Variable x, const Variable y) const {
84   return less(x, y);
85 }
86 
87 inline void
m_swap(Variable & v)88 Variable::m_swap(Variable& v) {
89   using std::swap;
90   swap(varid, v.varid);
91 }
92 
93 inline void
swap(Variable & x,Variable & y)94 swap(Variable& x, Variable& y) {
95   x.m_swap(y);
96 }
97 
98 } // namespace Parma_Polyhedra_Library
99 
100 #endif // !defined(PPL_Variable_inlines_hh)
101