APRONXX 0.9.15
/home/mine/apron/apronxx/apxx_generator1.hh
Go to the documentation of this file.
1/* -*- C++ -*-
2 * apxx_generator1.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_GENERATOR1_HH
17#define __APXX_GENERATOR1_HH
18
19#include "ap_generator1.h"
20#include "apxx_environment.hh"
21#include "apxx_generator0.hh"
22#include "apxx_linexpr1.hh"
23
24namespace apron {
25
26
27
28/* ================================= */
29/* generator1 */
30/* ================================= */
31
37
38 * reference count).
39 */
40class generator1 : public use_malloc {
41
42protected:
43
44 ap_generator1_t l;
47 generator1(ap_generator1_t p);
48
49 friend class generator1_array;
50
51public:
52
53
54 /* constructors */
55 /* ============ */
59
63 generator1(const environment& e, const generator0& x);
64
66
71 */
72 generator1(const environment& e, ap_gentyp_t gentyp=AP_GEN_RAY);
73
75
80 * \warning \c lin should have only scalar (non-interval) coefficients (unchecked).
81 */
82 generator1(ap_gentyp_t gentyp, const linexpr1& lin);
83
85 generator1(const generator1& x);
86
87
88 *
89 * \throw std::invalid_argument if e is not a super-environment of that of x.
90 */
91 generator1(const generator1& x, const environment& e);
92
94
95
96 /* destructor */
97 /* ========== */
98
101
105 ~generator1();
106
107
108
109
110 /* assignment */
111 /* ========== */
115
116
121
122 * it is created.
123 *
124 * \warning \c c should have only scalar (non-interval) coefficients (unchecked).
125 * \warning assumes that c and *this have equal environments (unchecked).
126 */
127 void set_linexpr(const linexpr1& c);
128
130
131
132 /* dimension operations */
133 /* ==================== */
134
136
141
143
145
146
147 /* access */
148 /* ====== */
149
152
157 const generator0& get_generator0() const;
158
161
162 /*! \brief Returns the size of the underlying linear expression.
163 *
164 * \throw std::invalid_argument if no valid linear expression has been defined.
165 */
166 size_t size() const;
167
168
169 /* get */
170
175 ap_gentyp_t& get_gentyp();
176
177
179 * \return either AP_GEN_LINE, AP_GEN_RAY, AP_GEN_VERTEX, AP_GEN_LINEMOD, or AP_GEN_RAYMOD.
180 */
181 const ap_gentyp_t& get_gentyp() const;
182
187
188 bool has_linexpr() const;
189
192 * \throw std::invalid_argument if no valid linear expression has been defined.
193 */
194 linexpr1 get_linexpr() const;
195
200 coeff& get_cst();
201
206 const coeff& get_cst() const;
211
213 coeff& operator[](const var& v);
214
217 * \throw std::invalid_argument if the variable name is not present in the environment.
218 * \throw std::invalid_argument if no valid linear expression has been defined.
219 */
220 const coeff& operator[](const var& v) const;
223
224
225 /* print */
226 /* ===== */
227
230
232 friend std::ostream& operator<< (std::ostream& os, const generator1& s);
233
235 void print(FILE* stream=stdout) const;
236
239
240 /* TODO: intelligent constructors */
242
243 /* C-level compatibility */
244 /* ===================== */
245
248
249 //! Returns a pointer to the internal APRON object stored in *this.
250 const ap_generator1_t* get_ap_generator1_t() const;
251
253 ap_generator1_t* get_ap_generator1_t();
256};
257
258
259
260/* ================================= */
261/* generator1_array */
262/* ================================= */
263
264
270
271 */
273
274protected:
275
276 ap_generator1_array_t a;
277
279 generator1_array(ap_generator1_array_t& a);
281 friend class abstract1;
282
283public:
284
285 /* constructors */
286 /* ============ */
287
289
290
298
301 generator1_array(const environment& e, size_t size);
302
303 //! (Deep) copy.
305
311
314
315 * \throw std::invalid_argument if size<1.
316 */
317 generator1_array(size_t size, const generator1 x[]);
318
324 generator1_array(const std::vector<generator1>& x);
325
326 //@}
327
328
329 /* destructor */
330 /* ========== */
331
334
339
341
342
343 /* assignment */
344 /* ========== */
345
351
352 /*! \brief Copies the generators from the array into *this.
353 *
354 * \warning assumes that all generators have the same environment (unchecked).
355 * \arg x should contain (at least) size elements.
356 */
358
359
363 generator1_array& operator= (const std::vector<generator1>& x);
366
367
368 /* dimension operations */
369 /* ==================== */
370
373
374 //! Resizes the array.
375 void resize(size_t size);
376
378
379 * \throw std::invalid_argument if e is not a super-environment of that of *this.
380 */
381 void extend_environment(const environment& e);
382
383
385
386 /* access */
387 /* ====== */
388
390
393 size_t size() const;
394
397
398
400
408 generator1 get(size_t i) const;
409
414
415 void set(size_t i, const generator1& x);
416
418
420 /* conversion */
421 /* ========== */
422
425
427 operator std::vector<generator1>() const;
430
431
432 /* print */
433 /* ===== */
434
441
442 */
443 friend std::ostream& operator<< (std::ostream& os, const generator1_array& s);
444
446 void print(FILE* stream=stdout) const;
447
449
450
451 /* C-level compatibility */
452 /* ===================== */
453
456
458 const ap_generator1_array_t* get_ap_generator1_array_t() const;
459
461 ap_generator1_array_t* get_ap_generator1_array_t();
462
464
465};
466
468
469}
470
471#endif /* __APXX_GENERATOR1_HH */
Coefficient (ap_coeff_t wrapper).
Definition apxx_coeff.hh:36
Level 1 environment (ap_environment_t wrapper).
Definition apxx_environment.hh:51
Array of generators (ap_generator0_array_t wrapper).
Definition apxx_generator0.hh:214
Level 0 generator (ap_generator0_t wrapper).
Definition apxx_generator0.hh:39
ap_generator1_array_t a
Structure managed by APRON.
Definition apxx_generator1.hh:276
size_t size() const
Returns the size of the array.
Definition apxx_generator1.hh:364
environment get_environment() const
Returns the environment shared by all generators (with incremented reference count).
Definition apxx_generator1.hh:369
void resize(size_t size)
Resizes the array.
Definition apxx_generator1.hh:347
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_generator1.hh:428
void extend_environment(const environment &e)
Extends the environment of all generators in the array.
Definition apxx_generator1.hh:352
friend std::ostream & operator<<(std::ostream &os, const generator1_array &s)
Printing.
Definition apxx_generator1.hh:419
generator1_array(ap_generator1_array_t &a)
Internal use only. Shallow copy (no copy of generator0_array or environment).
Definition apxx_generator1.hh:238
const ap_generator1_array_t * get_ap_generator1_array_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator1.hh:437
generator1_array & operator=(const generator1_array &x)
(Deep) copy.
Definition apxx_generator1.hh:303
ap_generator1_array_t * get_ap_generator1_array_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator1.hh:442
~generator1_array()
Frees the space used by the array and all its generators, and decrements the reference count of the e...
Definition apxx_generator1.hh:294
generator1 get(size_t i) const
Returns a copy of the generator at index i.
Definition apxx_generator1.hh:384
friend class abstract1
Definition apxx_generator1.hh:281
void set(size_t i, const generator1 &x)
Changes the generator at index i.
Definition apxx_generator1.hh:391
const generator0_array & get_generator0_array() const
Returns a reference to the underlying generator0_array.
Definition apxx_generator1.hh:374
Level 1 generator (ap_generator1_t wrapper).
Definition apxx_generator1.hh:40
ap_gentyp_t & get_gentyp()
Returns a (modifiable) reference to the constraint type.
Definition apxx_generator1.hh:132
bool has_linexpr() const
Whether the generator has a valid linear expression.
Definition apxx_generator1.hh:142
generator1 & operator=(const generator1 &x)
Makes a (deep) copy.
Definition apxx_generator1.hh:80
coeff & get_cst()
Returns a (modifiable) reference to the constant coefficient.
Definition apxx_generator1.hh:155
void set_linexpr(const linexpr1 &c)
Sets the underlying linear expression to c (copied).
Definition apxx_generator1.hh:88
ap_generator1_t l
Structure managed by APRON.
Definition apxx_generator1.hh:44
coeff & operator[](const var &v)
Returns a (modifiable) reference to the coefficient corresponding to the given variable name.
Definition apxx_generator1.hh:169
void extend_environment(const environment &e)
Extends the environment of the generator.
Definition apxx_generator1.hh:97
linexpr1 get_linexpr() const
Returns a copy of the underlying linear expression.
Definition apxx_generator1.hh:147
const ap_generator1_t * get_ap_generator1_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator1.hh:216
environment get_environment() const
Returns the environment of the generator (with incremented reference count).
Definition apxx_generator1.hh:112
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_generator1.hh:207
generator1(ap_generator1_t p)
Internal use only. Shallow copy (no copy of generator0 or environment).
Definition apxx_generator1.hh:29
const generator0 & get_generator0() const
Returns a reference to the underlying generator0.
Definition apxx_generator1.hh:117
~generator1()
Frees all space for the generator, and decrements the reference count of the environment.
Definition apxx_generator1.hh:71
size_t size() const
Returns the size of the underlying linear expression.
Definition apxx_generator1.hh:127
friend class generator1_array
Definition apxx_generator1.hh:49
friend std::ostream & operator<<(std::ostream &os, const generator1 &s)
Printing.
Definition apxx_generator1.hh:192
Level 1 linear expression (ap_linexpr1_t wrapper).
Definition apxx_linexpr1.hh:39
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