InputConsumer.h
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2011 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#ifndef INPUT_CONSUMER_GUARD
#define INPUT_CONSUMER_GUARD
#include "BigIdeal.h"
#include "SquareFreeIdeal.h"
#include "VarNames.h"
#include "ElementDeleter.h"
#include <vector>
#include <list>
#include <string>
class Scanner;
class InputConsumer {
public:
InputConsumer();
void consumeRing(const VarNames& names);
void requireSquareFree();
void beginIdeal();
void hintGenCount(size_t hintGenCount);
void beginTerm();
size_t consumeVar(Scanner& in);
size_t consumeVarNumber(Scanner& in);
void consumeVarExponentOne(size_t var, const Scanner& in);
void consumeVarExponent(size_t var, Scanner& in);
void endTerm();
void consumeTermProductNotation(Scanner& in);
void endIdeal();
bool empty() const {return _ideals.empty();}
void releaseIdeal(unique_ptr<SquareFreeIdeal>& sqf, unique_ptr<BigIdeal>& big);
unique_ptr<BigIdeal> releaseBigIdeal();
unique_ptr<SquareFreeIdeal> releaseSquareFreeIdeal();
const VarNames& getRing() const {return _names;}
private:
struct Entry {
unique_ptr<BigIdeal> _big;
unique_ptr<SquareFreeIdeal> _sqf;
};
void releaseIdeal(Entry& e);
void errorVariableAppearsTwice(const Scanner& in, size_t var);
void idealNotSquareFree();
static void toBigIdeal
(unique_ptr<SquareFreeIdeal>& sqf, unique_ptr<BigIdeal>& big);
string _tmpString;
VarNames _names;
unique_ptr<BigIdeal> _bigIdeal;
unique_ptr<SquareFreeIdeal> _sqfIdeal;
vector<string> _term;
std::list<Entry*> _ideals;
ElementDeleter<std::list<Entry*> > _idealsDeleter;
bool _inIdeal;
bool _requireSquareFree;
};
#endif
BigIdeal.h
ElementDeleter.h
SquareFreeIdeal.h
VarNames.h
ElementDeleter
Definition ElementDeleter.h:50
InputConsumer::releaseIdeal
void releaseIdeal(unique_ptr< SquareFreeIdeal > &sqf, unique_ptr< BigIdeal > &big)
Struct that keeps either a BigIdeal or a SquareFreeIdeal.
Definition InputConsumer.cpp:200
InputConsumer::requireSquareFree
void requireSquareFree()
Definition InputConsumer.cpp:45
InputConsumer::errorVariableAppearsTwice
void errorVariableAppearsTwice(const Scanner &in, size_t var)
Definition InputConsumer.cpp:234
InputConsumer::empty
bool empty() const
Returns true if there are ideals stored.
Definition InputConsumer.h:74
InputConsumer::_sqfIdeal
unique_ptr< SquareFreeIdeal > _sqfIdeal
Definition InputConsumer.h:108
InputConsumer::consumeVarNumber
size_t consumeVarNumber(Scanner &in)
Reads variable as a number so that the first variable is 1.
Definition InputConsumer.cpp:76
InputConsumer::idealNotSquareFree
void idealNotSquareFree()
Definition InputConsumer.cpp:241
InputConsumer::releaseBigIdeal
unique_ptr< BigIdeal > releaseBigIdeal()
Returns the least recently read ideal that has not been released.
Definition InputConsumer.cpp:209
InputConsumer::_tmpString
string _tmpString
Definition InputConsumer.h:105
InputConsumer::beginTerm
void beginTerm()
Start consuming a term.
Definition InputConsumer.cpp:62
InputConsumer::getRing
const VarNames & getRing() const
Returns the current ring.
Definition InputConsumer.h:91
InputConsumer::beginIdeal
void beginIdeal()
Start consuming an ideal.
Definition InputConsumer.cpp:50
InputConsumer::_requireSquareFree
bool _requireSquareFree
Definition InputConsumer.h:114
InputConsumer::_names
VarNames _names
Definition InputConsumer.h:106
InputConsumer::consumeVar
size_t consumeVar(Scanner &in)
Reads variable and returns id.
Definition InputConsumer.cpp:90
InputConsumer::_ideals
std::list< Entry * > _ideals
Definition InputConsumer.h:111
InputConsumer::consumeTermProductNotation
void consumeTermProductNotation(Scanner &in)
Reads a term in a format like "a^4*b*c^2".
Definition InputConsumer.cpp:148
InputConsumer::consumeRing
void consumeRing(const VarNames &names)
Definition InputConsumer.cpp:33
InputConsumer::releaseSquareFreeIdeal
unique_ptr< SquareFreeIdeal > releaseSquareFreeIdeal()
Returns the least recently read ideal that has not been released.
Definition InputConsumer.cpp:218
InputConsumer::InputConsumer
InputConsumer()
Definition InputConsumer.cpp:27
InputConsumer::consumeVarExponent
void consumeVarExponent(size_t var, Scanner &in)
Consumes var raised to an exponent read from in.
Definition InputConsumer.cpp:122
InputConsumer::hintGenCount
void hintGenCount(size_t hintGenCount)
Suggest that the current ideal will have the given number of generators.
Definition InputConsumer.cpp:57
InputConsumer::consumeVarExponentOne
void consumeVarExponentOne(size_t var, const Scanner &in)
Consumes var raised to the exponent 1.
Definition InputConsumer.cpp:102
InputConsumer::_idealsDeleter
ElementDeleter< std::list< Entry * > > _idealsDeleter
Definition InputConsumer.h:112
InputConsumer::_inIdeal
bool _inIdeal
Definition InputConsumer.h:113
InputConsumer::_bigIdeal
unique_ptr< BigIdeal > _bigIdeal
Definition InputConsumer.h:107
InputConsumer::endIdeal
void endIdeal()
Done reading an ideal.
Definition InputConsumer.cpp:191
InputConsumer::toBigIdeal
static void toBigIdeal(unique_ptr< SquareFreeIdeal > &sqf, unique_ptr< BigIdeal > &big)
Definition InputConsumer.cpp:247
InputConsumer::_term
vector< string > _term
Definition InputConsumer.h:109
InputConsumer::endTerm
void endTerm()
Done reading a term.
Definition InputConsumer.cpp:164
Scanner
This class offers an input interface which is more convenient and for some purposes more efficient th...
Definition Scanner.h:50
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40
InputConsumer::Entry
Definition InputConsumer.h:94
InputConsumer::Entry::_sqf
unique_ptr< SquareFreeIdeal > _sqf
Definition InputConsumer.h:96
InputConsumer::Entry::_big
unique_ptr< BigIdeal > _big
Definition InputConsumer.h:95