APRONXX 0.9.15
/home/mine/apron/apronxx/apxx_generator0.hh
Go to the documentation of this file.
1/* -*- C++ -*-
2 * apxx_generator0.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_GENERATOR0_HH
17#define __APXX_GENERATOR0_HH
18
19#include <vector>
20#include "ap_generator0.h"
21#include "apxx_linexpr0.hh"
22
23
24namespace apron {
25
26
27
28/* ================================= */
29/* generator0 */
30/* ================================= */
31
32
33
34 *
35 * A generator0 object represents a generator: vertex, ray, line, modular line, or modular ray.
36 * It stores and manages a linexpr0 (linear expression with scalar coefficients only),
37 * and a generator type (vertex, ray , etc).
38 */
39class generator0 : public use_malloc {
41protected:
42
43 ap_generator0_t l;
44
46 generator0(ap_generator0_t& l) : l(l) {}
47
48 friend class abstract0;
49
50public:
51
52
53 /* constructors */
54 /* ============ */
55
59
62 generator0(ap_gentyp_t gentyp=AP_GEN_RAY);
63
65 *
66 * \arg \c gentyp can be \c AP_GEN_LINE, \c AP_GEN_RAY, \c AP_GEN_VERTEX, \c AP_GEN_LINEMOD,
67 * or \c AP_GEN_RAYMOD.
68 *
69 * \warning \c lin should have only scalar (non-interval) coefficients (unchecked).
70 */
71 generator0(ap_gentyp_t gentyp, const linexpr0& lin);
72
75
77 generator0(const generator0& x, const dimchange& d);
78
80 generator0(const generator0& x, const dimperm& d);
81
82
83 /* destructor */
84 /* ========== */
85
88
89
90 /* assignment */
91 /* ========== */
92
93 //! (Deep) copy.
95
96
97 /* dimension operations */
98 /* ==================== */
104 void resize(size_t size);
105
110 void add_dimensions(const dimchange& d);
116 void permute_dimensions(const dimperm& d);
117
118
119 /* access */
120 /* ====== */
121
122 /* size */
123
124
126 * \throw std::invalid_argument if no valid linear expression has been defined.
127 */
128 size_t size() const;
129
131 /* get */
132
134
135 * \return either \c AP_GEN_LINE, \c AP_GEN_RAY, \c AP_GEN_VERTEX, \c AP_GEN_LINEMOD, or \c AP_GEN_RAYMOD.
136 */
137 ap_gentyp_t& get_gentyp();
138
140
141 * \return either \c AP_GEN_LINE, \c AP_GEN_RAY, \c AP_GEN_VERTEX, \c AP_GEN_LINEMOD, or \c AP_GEN_RAYMOD.
142 */
143 const ap_gentyp_t& get_gentyp() const;
144
146
147 * \note The only way the linear expression may be invalid is when accessing fields of uninitialised
148 * (or enlarged) generator0_array.
149 */
150 bool has_linexpr() const;
151
152
162 const linexpr0& get_linexpr() const;
163
170 void set_linexpr(const linexpr0& c);
171
172
173 /* print */
174 /* ===== */
175
177
182 friend std::ostream& operator<< (std::ostream& os, const generator0& s);
183
185 void print(char** name_of_dim=NULL, FILE* stream=stdout) const;
186
188 /* TODO: intelligent constructors */
189
190
191 /* C-level compatibility */
192 /* ===================== */
193
195 const ap_generator0_t* get_ap_generator0_t() const;
196
198 ap_generator0_t* get_ap_generator0_t();
199
200};
201
203
204
205/* ================================= */
206/* generator0_array */
207/* ================================= */
208
209
213
215
216protected:
217
218 ap_generator0_array_t a;
219
220
221 generator0_array(ap_generator0_array_t& a) : a(a) {}
222
223 friend class abstract0;
224 friend class generator1_array;
225
226public:
227
228 /* constructors */
229 /* ============ */
230
233
234 /*! \brief Creates a new array of the given size containing uninitialized generators.
235 *
236 * has_linexpr will return false on all elements of the array.
237 */
238 generator0_array(size_t size);
239
242
245
247 generator0_array(const generator0_array& x, const dimperm& d);
248
250 generator0_array(size_t size, const generator0 x[]);
251
253 generator0_array(const std::vector<generator0>& x);
254
256
257
258 /* destructor */
259 /* ========== */
260
262
266
268
269
270 /* assignment */
271 /* ========== */
272
273 /** @name Assignments */
275
278
282
284
286 generator0_array& operator= (const std::vector<generator0>& x);
289
290
291 /* dimension operations */
292 /* ==================== */
293
296
297 //! Resizes the array.
298 void resize(size_t size);
299
301 void add_dimensions(const dimchange& d);
302
304 void permute_dimensions(const dimperm& d);
305
306 //@}
307
308
309 /* access */
310 /* ====== */
314
315
316 size_t size() const;
317
320
321 //! Returns a pointer to the start of the internal array holding the generators.
322 const generator0* contents() const;
323
325 generator0& operator[](size_t i);
328 const generator0& operator[](size_t i) const;
329
330
332 * \throw std::out_of_range if the index is invalid.
333 */
334 generator0& get(size_t i);
335
336
338 * \throw std::out_of_range if the index is invalid.
339 */
340 const generator0& get(size_t i) const;
341
342
343
344
345 /* conversion */
346 /* ========== */
350
352 operator std::vector<generator0>() const;
353
355
356
357 /* print */
358 /* ===== */
359
360 /** @name Printing */
362
368
369 friend std::ostream& operator<< (std::ostream& os, const generator0_array& s);
370
372 void print(char** name_of_dim=NULL, FILE* stream=stdout) const;
373
375
376
377 /* C-level compatibility */
378 /* ===================== */
379
382
383 //! Returns a pointer to the internal APRON object stored in *this.
384 const ap_generator0_array_t* get_ap_generator0_array_t() const;
385
387 ap_generator0_array_t* get_ap_generator0_array_t();
388
390};
391
392
394
395}
396
397#endif /* __APXX_GENERATOR0_HH */
Dimension change object (ap_dimchange_t wrapper).
Definition apxx_dimension.hh:102
Dimension permutation object (ap_dimperm_t wrapper).
Definition apxx_dimension.hh:292
generator0 & get(size_t i)
Returns a (modifiable) reference to an element (bound-checked).
Definition apxx_generator0.hh:331
friend class abstract0
Definition apxx_generator0.hh:223
void permute_dimensions(const dimperm &d)
Applies permute_dimensions to all generators in the array.
Definition apxx_generator0.hh:297
const generator0 & operator[](size_t i) const
Returns a reference to an element, no bound checking.
Definition apxx_generator0.hh:326
size_t size() const
Returns the size of the array.
Definition apxx_generator0.hh:306
ap_generator0_array_t a
Structure managed by APRON.
Definition apxx_generator0.hh:218
ap_generator0_array_t * get_ap_generator0_array_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator0.hh:383
generator0_array(ap_generator0_array_t &a)
Internal use only. Performs a shallow copy and takes ownership of the contents.
Definition apxx_generator0.hh:221
void resize(size_t size)
Resizes the array.
Definition apxx_generator0.hh:287
generator0 & operator[](size_t i)
Returns a (modifiable) reference to an element, no bound checking.
Definition apxx_generator0.hh:321
generator0_array & operator=(const generator0_array &x)
(Deep) copy.
Definition apxx_generator0.hh:253
~generator0_array()
Frees the space used by the array and all its generators.
Definition apxx_generator0.hh:244
generator0 * contents()
Returns a pointer to the start of the internal array holding the generators.
Definition apxx_generator0.hh:311
friend std::ostream & operator<<(std::ostream &os, const generator0_array &s)
Printing.
Definition apxx_generator0.hh:360
const generator0 & get(size_t i) const
Returns a reference to an element (bound-checked).
Definition apxx_generator0.hh:337
void add_dimensions(const dimchange &d)
Applies add_dimensions to all generators in the array.
Definition apxx_generator0.hh:292
const ap_generator0_array_t * get_ap_generator0_array_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator0.hh:378
friend class generator1_array
Definition apxx_generator0.hh:224
void print(char **name_of_dim=NULL, FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_generator0.hh:369
Level 0 generator (ap_generator0_t wrapper).
Definition apxx_generator0.hh:39
generator0(ap_generator0_t &l)
Internal use only. Performs a shallow copy and takes ownership of the contents.
Definition apxx_generator0.hh:46
void set_linexpr(const linexpr0 &c)
Sets the underlying linear expression to c (copied).
Definition apxx_generator0.hh:147
friend class abstract0
Definition apxx_generator0.hh:48
generator0 & operator=(const generator0 &x)
(Deep) copy.
Definition apxx_generator0.hh:74
void permute_dimensions(const dimperm &d)
Applies a permutation to the underlying linear expression.
Definition apxx_generator0.hh:99
bool has_linexpr() const
Returns whether the generator has a valid linear expression.
Definition apxx_generator0.hh:130
ap_generator0_t * get_ap_generator0_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator0.hh:187
ap_gentyp_t & get_gentyp()
Returns a (modifiable) reference to the constraint type.
Definition apxx_generator0.hh:120
void resize(size_t size)
Resizes the underlying linear expression.
Definition apxx_generator0.hh:87
const ap_generator0_t * get_ap_generator0_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_generator0.hh:182
linexpr0 & get_linexpr()
Returns a (modifiable) reference to the underlying linear expression.
Definition apxx_generator0.hh:135
void print(char **name_of_dim=NULL, FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_generator0.hh:173
ap_generator0_t l
Structure managed by APRON.
Definition apxx_generator0.hh:43
size_t size() const
Returns the size of the underlying linear expression.
Definition apxx_generator0.hh:111
friend std::ostream & operator<<(std::ostream &os, const generator0 &s)
Printing.
Definition apxx_generator0.hh:157
void add_dimensions(const dimchange &d)
Changes the dimension of the underlying linear expression.
Definition apxx_generator0.hh:93
~generator0()
Frees the generator, including the embedded linear expression.
Definition apxx_generator0.hh:65
Level 0 linear expression (ap_linexpr0_t wrapper).
Definition apxx_linexpr0.hh:44
Definition apxx_abstract0.hh:27
Inherited by most wrappers to map new and delete to malloc and free.
Definition apxx_scalar.hh:69