1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | |
---|
3 | #ifndef INCL_CF_GENERATOR_H |
---|
4 | #define INCL_CF_GENERATOR_H |
---|
5 | |
---|
6 | // #include "config.h" |
---|
7 | |
---|
8 | #include "canonicalform.h" |
---|
9 | |
---|
10 | /*BEGINPUBLIC*/ |
---|
11 | |
---|
12 | /** |
---|
13 | * virtual class for generators |
---|
14 | **/ |
---|
15 | class CFGenerator |
---|
16 | { |
---|
17 | public: |
---|
18 | CFGenerator() {} |
---|
19 | virtual ~CFGenerator() {} |
---|
20 | virtual bool hasItems() const { return false; } |
---|
21 | virtual void reset() {}; |
---|
22 | virtual CanonicalForm item() const { return 0; } |
---|
23 | virtual void next() {}; |
---|
24 | virtual CFGenerator * clone() const { return new CFGenerator();} |
---|
25 | }; |
---|
26 | |
---|
27 | /** |
---|
28 | * generate integers starting from 0 |
---|
29 | **/ |
---|
30 | class IntGenerator : public CFGenerator |
---|
31 | { |
---|
32 | private: |
---|
33 | int current; |
---|
34 | public: |
---|
35 | IntGenerator() : current(0) {} |
---|
36 | ~IntGenerator() {} |
---|
37 | bool hasItems() const; |
---|
38 | void reset() { current = 0; } |
---|
39 | CanonicalForm item() const; |
---|
40 | void next(); |
---|
41 | void operator++ () { next(); } |
---|
42 | void operator++ ( int ) { next(); } |
---|
43 | CFGenerator * clone() const; |
---|
44 | }; |
---|
45 | |
---|
46 | /** |
---|
47 | * generate all elements in F_p starting from 0 |
---|
48 | **/ |
---|
49 | class FFGenerator : public CFGenerator |
---|
50 | { |
---|
51 | private: |
---|
52 | int current; |
---|
53 | public: |
---|
54 | FFGenerator() : current(0) {} |
---|
55 | ~FFGenerator() {} |
---|
56 | bool hasItems() const; |
---|
57 | void reset() { current = 0; } |
---|
58 | CanonicalForm item() const; |
---|
59 | void next(); |
---|
60 | void operator++ () { next(); } |
---|
61 | void operator++ ( int ) { next(); } |
---|
62 | CFGenerator * clone() const; |
---|
63 | }; |
---|
64 | |
---|
65 | /** |
---|
66 | * generate all elements in GF starting from 0 |
---|
67 | **/ |
---|
68 | class GFGenerator : public CFGenerator |
---|
69 | { |
---|
70 | private: |
---|
71 | int current; |
---|
72 | public: |
---|
73 | GFGenerator(); |
---|
74 | ~GFGenerator() {} |
---|
75 | bool hasItems() const; |
---|
76 | void reset(); |
---|
77 | CanonicalForm item() const; |
---|
78 | void next(); |
---|
79 | void operator++ () { next(); } |
---|
80 | void operator++ ( int ) { next(); } |
---|
81 | CFGenerator * clone() const; |
---|
82 | }; |
---|
83 | |
---|
84 | /** |
---|
85 | * generate all elements in F_p(alpha) starting from 0 |
---|
86 | **/ |
---|
87 | class AlgExtGenerator: public CFGenerator |
---|
88 | { |
---|
89 | private: |
---|
90 | Variable algext; |
---|
91 | FFGenerator **gensf; |
---|
92 | GFGenerator **gensg; |
---|
93 | int n; |
---|
94 | bool nomoreitems; |
---|
95 | AlgExtGenerator(); |
---|
96 | AlgExtGenerator( const AlgExtGenerator & ); |
---|
97 | AlgExtGenerator& operator= ( const AlgExtGenerator & ); |
---|
98 | public: |
---|
99 | AlgExtGenerator( const Variable & a ); |
---|
100 | ~AlgExtGenerator(); |
---|
101 | |
---|
102 | bool hasItems() const { return ! nomoreitems; } |
---|
103 | void reset(); |
---|
104 | CanonicalForm item() const; |
---|
105 | void next(); |
---|
106 | void operator++ () { next(); } |
---|
107 | void operator++ ( int ) { next(); } |
---|
108 | CFGenerator * clone() const; |
---|
109 | }; |
---|
110 | |
---|
111 | class CFGenFactory |
---|
112 | { |
---|
113 | public: |
---|
114 | static CFGenerator* generate(); |
---|
115 | }; |
---|
116 | |
---|
117 | /*ENDPUBLIC*/ |
---|
118 | |
---|
119 | #endif /* ! INCL_CF_GENERATOR_H */ |
---|