Frobby 0.10.0
Loading...
Searching...
No Matches
InputConsumer.h
1/* Frobby: Software for monomial ideal computations.
2 Copyright (C) 2011 Bjarke Hammersholt Roune (www.broune.com)
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see http://www.gnu.org/licenses/.
16*/
17#ifndef INPUT_CONSUMER_GUARD
18#define INPUT_CONSUMER_GUARD
19
20#include "BigIdeal.h"
21#include "SquareFreeIdeal.h"
22#include "VarNames.h"
23#include "ElementDeleter.h"
24#include <vector>
25#include <list>
26#include <string>
27
28class Scanner;
29
30class InputConsumer {
31 public:
32 InputConsumer();
33
34 void consumeRing(const VarNames& names);
35
36 void requireSquareFree();
37
39 void beginIdeal();
40
44 void hintGenCount(size_t hintGenCount);
45
47 void beginTerm();
48
50 size_t consumeVar(Scanner& in);
51
54 size_t consumeVarNumber(Scanner& in);
55
57 void consumeVarExponentOne(size_t var, const Scanner& in);
58
62 void consumeVarExponent(size_t var, Scanner& in);
63
65 void endTerm();
66
69
71 void endIdeal();
72
74 bool empty() const {return _ideals.empty();}
75
77
80 void releaseIdeal(unique_ptr<SquareFreeIdeal>& sqf, unique_ptr<BigIdeal>& big);
81
84 unique_ptr<BigIdeal> releaseBigIdeal();
85
88 unique_ptr<SquareFreeIdeal> releaseSquareFreeIdeal();
89
91 const VarNames& getRing() const {return _names;}
92
93 private:
94 struct Entry {
95 unique_ptr<BigIdeal> _big;
96 unique_ptr<SquareFreeIdeal> _sqf;
97 };
98 void releaseIdeal(Entry& e);
99
100 void errorVariableAppearsTwice(const Scanner& in, size_t var);
101 void idealNotSquareFree();
102 static void toBigIdeal
103 (unique_ptr<SquareFreeIdeal>& sqf, unique_ptr<BigIdeal>& big);
104
105 string _tmpString;
106 VarNames _names;
107 unique_ptr<BigIdeal> _bigIdeal;
108 unique_ptr<SquareFreeIdeal> _sqfIdeal;
109 vector<string> _term;
110
111 std::list<Entry*> _ideals;
112 ElementDeleter<std::list<Entry*> > _idealsDeleter;
113 bool _inIdeal;
114 bool _requireSquareFree;
115};
116
117#endif
void releaseIdeal(unique_ptr< SquareFreeIdeal > &sqf, unique_ptr< BigIdeal > &big)
Definition InputConsumer.cpp:200
bool empty() const
Definition InputConsumer.h:74
size_t consumeVarNumber(Scanner &in)
Definition InputConsumer.cpp:76
unique_ptr< BigIdeal > releaseBigIdeal()
Definition InputConsumer.cpp:209
void beginTerm()
Definition InputConsumer.cpp:62
const VarNames & getRing() const
Definition InputConsumer.h:91
void beginIdeal()
Definition InputConsumer.cpp:50
size_t consumeVar(Scanner &in)
Definition InputConsumer.cpp:90
void consumeTermProductNotation(Scanner &in)
Definition InputConsumer.cpp:148
unique_ptr< SquareFreeIdeal > releaseSquareFreeIdeal()
Definition InputConsumer.cpp:218
void consumeVarExponent(size_t var, Scanner &in)
Definition InputConsumer.cpp:122
void hintGenCount(size_t hintGenCount)
Definition InputConsumer.cpp:57
void consumeVarExponentOne(size_t var, const Scanner &in)
Definition InputConsumer.cpp:102
void endIdeal()
Definition InputConsumer.cpp:191
void endTerm()
Definition InputConsumer.cpp:164
Definition Scanner.h:50
Definition VarNames.h:38