APRONXX  0.9.12
/builddir/build/BUILD/apron-0.9.13/apronxx/apxx_environment.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * apxx_environment.hh
3  *
4  * APRON Library / C++ class wrappers
5  *
6  * Copyright (C) Antoine Mine' 2007
7  *
8  */
9 /* This file is part of the APRON Library, released under LGPL license
10  with an exception allowing the redistribution of statically linked
11  executables.
12 
13  Please read the COPYING file packaged in the distribution.
14 */
15 
16 #ifndef __APXX_ENVIRONMENT_HH
17 #define __APXX_ENVIRONMENT_HH
18 
19 #include <string>
20 #include <vector>
21 
22 #include "ap_environment.h"
23 #include "apxx_dimension.hh"
24 #include "apxx_var.hh"
25 
26 
27 namespace apron {
28 
29 
30 /* ================================= */
31 /* environment */
32 /* ================================= */
33 
51 class environment : public use_malloc {
52 
53 protected:
54 
55  ap_environment_t* e;
56 
58  environment(ap_environment_t* x) : e(x) {}
59 
60  friend class linexpr1;
61  friend class lincons1;
62  friend class lincons1_array;
63  friend class generator1;
64  friend class generator1_array;
65  friend class texpr1;
66  friend class tcons1;
67  friend class tcons1_array;
68  friend class abstract1;
69 
70 public:
71 
72 
73  /* constructors */
74  /* ============ */
75 
76 
79 
81  environment();
82 
87  environment(const std::vector<var>& intdim, const std::vector<var>& realdim);
88 
93  environment(const var* intdim, size_t intdim_size, const var* realdim, size_t realdim_size);
94 
96  environment(const environment& x);
97 
99 
100 
103 
105  ~environment();
106 
108 
109 
110  /* assignment */
111  /* ========== */
112 
115 
117  const environment& operator=(const environment& x);
118 
120 
121 
122  /* operations */
123  /* ========== */
124 
127 
132  environment add(const std::vector<var>& intdim, const std::vector<var>& realdim) const;
133 
138  environment add(const var* intdim, size_t intdim_size, const var* realdim, size_t realdim_size) const;
139 
147  environment add(const std::vector<var>& intdim, const std::vector<var>& realdim, dimperm& perm) const;
148 
156  environment add(const var* intdim, size_t intdim_size, const var* realdim, size_t realdim_size, dimperm& perm) const;
157 
162  environment remove(const std::vector<var>& dims) const;
163 
168  environment remove(const var* dims, size_t dims_size) const;
169 
176  environment rename(const std::vector<std::pair<var,var> >& dims) const;
177 
184  environment rename(const var* before, const var* after, size_t dims_size) const;
185 
194  environment rename(const std::vector<std::pair<var,var> >& dims, dimperm& perm) const;
195 
204  environment rename(const var* before, const var* after, size_t dims_size, dimperm& perm) const;
205 
210  friend environment lce(const environment& x, const environment& y);
211 
219  friend environment lce(const environment& x, const environment& y, dimchange& chgx, dimchange& chgy);
220 
225  friend environment lce(const std::vector<environment>& x);
226 
231  friend environment lce(const environment* env, size_t env_size);
232 
241  friend environment lce(const std::vector<environment>& x, std::vector<dimchange>& chg);
242 
251  friend environment lce(const environment* env, dimchange* chg, size_t env_size);
252 
257  friend dimchange get_dimchange(const environment& x, const environment& y);
258 
260 
261 
262  /* access */
263  /* ====== */
264 
267 
269  size_t intdim() const;
270 
272  size_t realdim() const;
273 
275  bool contains(const var& x) const;
276 
281  ap_dim_t operator[] (const var& x) const;
282 
284  const var& operator[] (ap_dim_t d) const;
285 
290  ap_dim_t get_dim(const var& x) const;
291 
296  const var& get_var(ap_dim_t d) const;
297 
299  std::vector<var> get_vars() const;
300 
301 
303 
304 
305  /* Tests */
306  /* ===== */
307 
310 
312  friend bool operator==(const environment& x, const environment& y);
313 
315  friend bool operator!=(const environment& x, const environment& y);
316 
318  friend bool operator<=(const environment& x, const environment& y);
319 
321  friend bool operator>=(const environment& x, const environment& y);
322 
332  friend int cmp(const environment& x, const environment& y);
333 
335 
336 
337  /* print */
338  /* ===== */
339 
342 
344  friend std::ostream& operator<< (std::ostream& os, const environment& s);
345 
347  void print(FILE* stream=stdout) const;
348 
350 
351 
352  /* C API compatibility */
353  /* =================== */
354 
357 
359  const ap_environment_t* get_ap_environment_t() const;
360 
362  ap_environment_t* get_ap_environment_t();
363 
365 
366 };
367 
369 
370 }
371 
372 #endif /* __APXX_ENVIRONMENT_HH */
Level 1 abstract value (ap_abstract1_t wrapper).
Definition: apxx_abstract1.hh:42
Dimension change object (ap_dimchange_t wrapper).
Definition: apxx_dimension.hh:102
Dimension permutation object (ap_dimperm_t wrapper).
Definition: apxx_dimension.hh:292
Level 1 environment (ap_environment_t wrapper).
Definition: apxx_environment.hh:51
const ap_environment_t * get_ap_environment_t() const
Returns a pointer to the internal APRON object pointed by *this.
Definition: apxx_environment_inline.hh:425
ap_environment_t * e
Definition: apxx_environment.hh:55
friend int cmp(const environment &x, const environment &y)
Environment comparison.
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition: apxx_environment_inline.hh:416
size_t realdim() const
Returns the number of real dimensions in the environment.
Definition: apxx_environment_inline.hh:332
friend environment lce(const std::vector< environment > &x)
Returns the least common environment of a vector of environments.
const environment & operator=(const environment &x)
Assignment (reference counter manipulation).
Definition: apxx_environment_inline.hh:79
environment add(const std::vector< var > &intdim, const std::vector< var > &realdim) const
Returns a copy of the environment with some integer and/or real variable names added.
Definition: apxx_environment_inline.hh:92
friend std::ostream & operator<<(std::ostream &os, const environment &s)
Printing.
environment remove(const std::vector< var > &dims) const
Returns a copy of the environment with some variable names removed.
Definition: apxx_environment_inline.hh:139
std::vector< var > get_vars() const
Returns (a copy of) the full map from dimensions to variable names.
Definition: apxx_environment_inline.hh:367
friend environment lce(const environment *env, size_t env_size)
Returns the least common environment of an array env of env_size environments.
friend environment lce(const environment *env, dimchange *chg, size_t env_size)
Returns the least common environment of an array env of env_size environments.
bool contains(const var &x) const
Whether the environment contains the variable name x.
Definition: apxx_environment_inline.hh:337
ap_dim_t get_dim(const var &x) const
Returns the dimension associated with a variable name.
Definition: apxx_environment_inline.hh:354
friend bool operator==(const environment &x, const environment &y)
Equality testing.
friend environment lce(const environment &x, const environment &y, dimchange &chgx, dimchange &chgy)
Returns the least common environment of two environments.
friend environment lce(const std::vector< environment > &x, std::vector< dimchange > &chg)
Returns the least common environment of a vector of environments.
friend environment lce(const environment &x, const environment &y)
Returns the least common environment of two environments.
ap_dim_t operator[](const var &x) const
Returns the dimension associated with the variable name.
Definition: apxx_environment_inline.hh:342
size_t intdim() const
Returns the number of integer dimensions in the environment.
Definition: apxx_environment_inline.hh:327
const var & get_var(ap_dim_t d) const
Returns the variable name at a given dimension (bound-checked).
Definition: apxx_environment_inline.hh:361
friend bool operator!=(const environment &x, const environment &y)
Disequality testing.
environment()
Creates a new empty environment.
Definition: apxx_environment_inline.hh:44
environment(ap_environment_t *x)
Used internally only. Wraps the APRON object in an environment object (no copy, no change in referenc...
Definition: apxx_environment.hh:58
friend bool operator>=(const environment &x, const environment &y)
Inclusion testing.
friend bool operator<=(const environment &x, const environment &y)
Inclusion testing.
environment rename(const std::vector< std::pair< var, var > > &dims) const
Returns a copy of the environment with some variable names substituted.
Definition: apxx_environment_inline.hh:158
~environment()
Decrements the reference counter and, if null, actually frees the environment.
Definition: apxx_environment_inline.hh:70
friend dimchange get_dimchange(const environment &x, const environment &y)
Returns the dimension change to transform an environment x into a super-environment y.
Array of generators (ap_generator1_array_t wrapper).
Definition: apxx_generator1.hh:272
Level 1 generator (ap_generator1_t wrapper).
Definition: apxx_generator1.hh:40
Array of linear constraints (ap_lincons1_array_t wrapper).
Definition: apxx_lincons1.hh:331
Level 1 linear constraint (ap_lincons1_t wrapper).
Definition: apxx_lincons1.hh:40
Level 1 linear expression (ap_linexpr1_t wrapper).
Definition: apxx_linexpr1.hh:39
Array of arbitrary constraints (ap_tcons1_array_t wrapper).
Definition: apxx_tcons1.hh:337
Level 1 arbitrary constraint (ap_tcons1_t wrapper).
Definition: apxx_tcons1.hh:39
Level 1 arbitrary expression tree (ap_texpr1_t wrapper).
Definition: apxx_texpr1.hh:42
Variable name (ap_var_t wrapper).
Definition: apxx_var.hh:39
Definition: apxx_abstract0.hh:27
Inherited by most wrappers to map new and delete to malloc and free.
Definition: apxx_scalar.hh:69