IOHandler.h
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 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 IO_HANDLER_GUARD
#define IO_HANDLER_GUARD
#include <vector>
class Term;
class Scanner;
class BigIdeal;
class VarNames;
class BigTermConsumer;
class DataType;
class CoefBigTermConsumer;
class SatBinomConsumer;
class InputConsumer;
class IOHandler {
public:
virtual ~IOHandler();
void readIdeal(Scanner& in, InputConsumer& consumer);
void readIdeals(Scanner& in, InputConsumer& consumer);
void readTerm
(Scanner& in, const VarNames& names, vector<mpz_class>& term);
void readPolynomial(Scanner& in, CoefBigTermConsumer& consumer);
void readSatBinomIdeal(Scanner& in, SatBinomConsumer& consumer);
void writeTerm
(const vector<mpz_class>& term, const VarNames& names, FILE* out);
bool hasMoreInput(Scanner& in) const;
const char* getName() const;
const char* getDescription() const;
unique_ptr<BigTermConsumer> createIdealWriter(FILE* out);
unique_ptr<BigTermConsumer> createIdealListWriter(FILE* out);
unique_ptr<CoefBigTermConsumer> createPolynomialWriter(FILE* out);
bool supportsInput(const DataType& type) const;
bool supportsOutput(const DataType& type) const;
protected:
virtual BigTermConsumer* doCreateIdealWriter(FILE* out) = 0;
virtual CoefBigTermConsumer* doCreatePolynomialWriter(FILE* out) = 0;
private:
virtual const char* doGetName() const = 0;
virtual const char* doGetDescription() const = 0;
virtual void doReadIdeal(Scanner& in, InputConsumer& consumer) = 0;
virtual void doReadIdeals(Scanner& in, InputConsumer& consumer) = 0;
virtual void doReadTerm(Scanner& in, InputConsumer& consumer) = 0;
virtual void doReadPolynomial(Scanner& in, CoefBigTermConsumer& consumer) = 0;
virtual void doReadSatBinomIdeal(Scanner& in, SatBinomConsumer& consumer) = 0;
virtual void doWriteTerm(const vector<mpz_class>& term,
const VarNames& names,
FILE* out) = 0;
virtual bool doHasMoreInput(Scanner& in) const = 0;
virtual bool doSupportsInput(const DataType& type) const = 0;
virtual bool doSupportsOutput(const DataType& type) const = 0;
};
unique_ptr<IOHandler> createIOHandler(const string& prefix);
unique_ptr<IOHandler> createOHandler(const string& input, const string& output);
void getIOHandlerNames(vector<string>& names);
void readFrobeniusInstance(Scanner& in, vector<mpz_class>& numbers);
string autoDetectFormat(Scanner& in);
string getFormatNameIndicatingToGuessTheInputFormat();
string getFormatNameIndicatingToUseInputFormatAsOutputFormat();
#endif
readFrobeniusInstance
void readFrobeniusInstance(Scanner &in, vector< mpz_class > &numbers)
Definition IOHandler.cpp:160
getIOHandlerNames
void getIOHandlerNames(vector< string > &names)
Add the name of each fomat to names.
Definition IOHandler.cpp:156
getFormatNameIndicatingToUseInputFormatAsOutputFormat
string getFormatNameIndicatingToUseInputFormatAsOutputFormat()
Using the returned string in place of an (output) format name indicates to use the input format as th...
Definition IOHandler.cpp:230
getFormatNameIndicatingToGuessTheInputFormat
string getFormatNameIndicatingToGuessTheInputFormat()
Using the returned string in place of an (input) format name indicates to guess the format based on w...
Definition IOHandler.cpp:234
createOHandler
unique_ptr< IOHandler > createOHandler(const string &input, const string &output)
Returns an IOHandler for the output format.
Definition IOHandler.cpp:149
createIOHandler
unique_ptr< IOHandler > createIOHandler(const string &prefix)
Returns an IOHandler for the format whose name has the given prefix.
Definition IOHandler.cpp:145
autoDetectFormat
string autoDetectFormat(Scanner &in)
Return the format of what in is reading based on the first non-whitespace character.
Definition IOHandler.cpp:198
BigIdeal
Definition BigIdeal.h:27
BigTermConsumer
Definition BigTermConsumer.h:29
CoefBigTermConsumer
Definition CoefBigTermConsumer.h:29
DataType
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
Definition DataType.h:29
IOHandler
An IOHandler implements input and output for some format in such a way that client code does not need...
Definition IOHandler.h:41
IOHandler::doWriteTerm
virtual void doWriteTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)=0
IOHandler::doReadSatBinomIdeal
virtual void doReadSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)=0
IOHandler::readSatBinomIdeal
void readSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)
Definition IOHandler.cpp:68
IOHandler::readPolynomial
void readPolynomial(Scanner &in, CoefBigTermConsumer &consumer)
Definition IOHandler.cpp:64
IOHandler::doSupportsInput
virtual bool doSupportsInput(const DataType &type) const =0
IOHandler::doReadIdeals
virtual void doReadIdeals(Scanner &in, InputConsumer &consumer)=0
IOHandler::doCreatePolynomialWriter
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)=0
IOHandler::writeTerm
void writeTerm(const vector< mpz_class > &term, const VarNames &names, FILE *out)
Definition IOHandler.cpp:72
IOHandler::doReadPolynomial
virtual void doReadPolynomial(Scanner &in, CoefBigTermConsumer &consumer)=0
IOHandler::doGetDescription
virtual const char * doGetDescription() const =0
IOHandler::doCreateIdealWriter
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)=0
IOHandler::readIdeal
void readIdeal(Scanner &in, InputConsumer &consumer)
Read an ideal and feed it to the consumer.
Definition IOHandler.cpp:42
IOHandler::supportsInput
bool supportsInput(const DataType &type) const
Definition IOHandler.cpp:119
IOHandler::getName
const char * getName() const
Definition IOHandler.cpp:81
IOHandler::createIdealWriter
unique_ptr< BigTermConsumer > createIdealWriter(FILE *out)
Definition IOHandler.cpp:89
IOHandler::doSupportsOutput
virtual bool doSupportsOutput(const DataType &type) const =0
IOHandler::doReadIdeal
virtual void doReadIdeal(Scanner &in, InputConsumer &consumer)=0
IOHandler::createIdealListWriter
unique_ptr< BigTermConsumer > createIdealListWriter(FILE *out)
Definition IOHandler.cpp:98
IOHandler::doGetName
virtual const char * doGetName() const =0
IOHandler::getDescription
const char * getDescription() const
Definition IOHandler.cpp:85
IOHandler::doHasMoreInput
virtual bool doHasMoreInput(Scanner &in) const =0
IOHandler::supportsOutput
bool supportsOutput(const DataType &type) const
Definition IOHandler.cpp:123
IOHandler::createPolynomialWriter
unique_ptr< CoefBigTermConsumer > createPolynomialWriter(FILE *out)
Definition IOHandler.cpp:110
IOHandler::doReadTerm
virtual void doReadTerm(Scanner &in, InputConsumer &consumer)=0
IOHandler::readTerm
void readTerm(Scanner &in, const VarNames &names, vector< mpz_class > &term)
Definition IOHandler.cpp:51
IOHandler::~IOHandler
virtual ~IOHandler()
Definition IOHandler.cpp:39
IOHandler::hasMoreInput
bool hasMoreInput(Scanner &in) const
Definition IOHandler.cpp:77
IOHandler::readIdeals
void readIdeals(Scanner &in, InputConsumer &consumer)
Read a number of ideals and feed them to the consumer.
Definition IOHandler.cpp:46
InputConsumer
Definition InputConsumer.h:30
SatBinomConsumer
Definition SatBinomConsumer.h:25
Scanner
This class offers an input interface which is more convenient and for some purposes more efficient th...
Definition Scanner.h:50
Term
Term represents a product of variables which does not include a coefficient.
Definition Term.h:49
VarNames
Defines the variables of a polynomial ring and facilities IO involving them.
Definition VarNames.h:40