IOHandlerImpl.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_IMPL_GUARD
#define IO_HANDLER_IMPL_GUARD
#include "IOHandler.h"
#include <vector>
class Term;
class Scanner;
class BigIdeal;
class VarNames;
class BigTermConsumer;
class DataType;
class CoefBigTermConsumer;
class SatBinomConsumer;
class TermTranslator;
class BigPolynomial;
namespace IO {
class IOHandlerImpl : public IOHandler {
protected:
IOHandlerImpl(const char* formatName,
const char* formatDescription);
void registerInput(const DataType& type);
void registerOutput(const DataType& type);
private:
// The following methods have implementations that merely report
// an internal error. Make sure to override those you register
// support for.
virtual BigTermConsumer* doCreateIdealWriter(FILE* out) = 0;
virtual CoefBigTermConsumer* doCreatePolynomialWriter(FILE* out);
virtual void doReadTerm(Scanner& in, InputConsumer& term);
virtual void doReadIdeal(Scanner& in, InputConsumer& consumer);
virtual void doReadIdeals(Scanner& in, InputConsumer& consumer);
virtual void doReadPolynomial(Scanner& in, CoefBigTermConsumer& consumer);
virtual void doReadSatBinomIdeal(Scanner& in, SatBinomConsumer& consumer);
// The following methods are implemented with the suggested
// behavior
virtual const char* doGetName() const;
virtual const char* doGetDescription() const;
virtual bool doSupportsInput(const DataType& type) const;
virtual bool doSupportsOutput(const DataType& type) const;
virtual bool doHasMoreInput(Scanner& in) const;
vector<const DataType*> _supportedInputs;
vector<const DataType*> _supportedOutputs;
const char* _formatName;
const char* _formatDescription;
};
void writeCoefTermProduct(const mpz_class& coef,
const Term& term,
const TermTranslator& translator,
bool hidePlus,
FILE* out);
void writeCoefTermProduct(const mpz_class& coef,
const vector<mpz_class>& term,
const VarNames& names,
bool hidePlus,
FILE* out);
void writeTermProduct(const Term& term,
const TermTranslator& translator,
FILE* out);
void writeTermProduct(const vector<mpz_class>& term,
const VarNames& names,
FILE* out);
void readTermProduct(Scanner& in,
const VarNames& names,
vector<mpz_class>& term);
void readTermProduct(BigIdeal& ideal, Scanner& in);
void readCoefTerm(BigPolynomial& polynomial,
bool firstTerm,
Scanner& in);
void readCoefTerm(mpz_class& coef,
vector<mpz_class>& term,
const VarNames& names,
bool firstTerm,
Scanner& in);
void readVarPower(vector<mpz_class>& term,
const VarNames& names,
Scanner& in);
}
#endif
IOHandler.h
BigIdeal
Definition BigIdeal.h:27
BigPolynomial
Definition BigPolynomial.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
IO::IOHandlerImpl::registerInput
void registerInput(const DataType &type)
Specify that input of the argument type is supported.
Definition IOHandlerImpl.cpp:60
IO::IOHandlerImpl::doReadTerm
virtual void doReadTerm(Scanner &in, InputConsumer &term)
Definition IOHandlerImpl.cpp:74
IO::IOHandlerImpl::doReadSatBinomIdeal
virtual void doReadSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)
Definition IOHandlerImpl.cpp:91
IO::IOHandlerImpl::_formatDescription
const char * _formatDescription
Definition IOHandlerImpl.h:73
IO::IOHandlerImpl::doCreateIdealWriter
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)=0
Definition IOHandlerImpl.cpp:42
IO::IOHandlerImpl::doSupportsInput
virtual bool doSupportsInput(const DataType &type) const
Definition IOHandlerImpl.cpp:50
IO::IOHandlerImpl::doReadIdeal
virtual void doReadIdeal(Scanner &in, InputConsumer &consumer)
Definition IOHandlerImpl.cpp:78
IO::IOHandlerImpl::doGetDescription
virtual const char * doGetDescription() const
Definition IOHandlerImpl.cpp:104
IO::IOHandlerImpl::doGetName
virtual const char * doGetName() const
Definition IOHandlerImpl.cpp:100
IO::IOHandlerImpl::doSupportsOutput
virtual bool doSupportsOutput(const DataType &type) const
Definition IOHandlerImpl.cpp:55
IO::IOHandlerImpl::IOHandlerImpl
IOHandlerImpl(const char *formatName, const char *formatDescription)
Definition IOHandlerImpl.cpp:36
IO::IOHandlerImpl::doHasMoreInput
virtual bool doHasMoreInput(Scanner &in) const
Definition IOHandlerImpl.cpp:96
IO::IOHandlerImpl::_supportedOutputs
vector< const DataType * > _supportedOutputs
Definition IOHandlerImpl.h:70
IO::IOHandlerImpl::doCreatePolynomialWriter
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
Definition IOHandlerImpl.cpp:46
IO::IOHandlerImpl::doReadPolynomial
virtual void doReadPolynomial(Scanner &in, CoefBigTermConsumer &consumer)
Definition IOHandlerImpl.cpp:86
IO::IOHandlerImpl::doReadIdeals
virtual void doReadIdeals(Scanner &in, InputConsumer &consumer)
Definition IOHandlerImpl.cpp:82
IO::IOHandlerImpl::registerOutput
void registerOutput(const DataType &type)
Specify that output of the argument type is supported.
Definition IOHandlerImpl.cpp:67
IO::IOHandlerImpl::_formatName
const char * _formatName
Definition IOHandlerImpl.h:72
IO::IOHandlerImpl::_supportedInputs
vector< const DataType * > _supportedInputs
Definition IOHandlerImpl.h:69
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
TermTranslator
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Definition TermTranslator.h:41
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
IO
Definition CoCoA4IOHandler.cpp:33
IO::writeCoefTermProduct
void writeCoefTermProduct(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool hidePlus, FILE *out)
Definition IOHandlerImpl.cpp:123
IO::readVarPower
void readVarPower(vector< mpz_class > &term, const VarNames &names, Scanner &in)
Definition IOHandlerImpl.cpp:272
IO::readCoefTerm
void readCoefTerm(BigPolynomial &polynomial, bool firstTerm, Scanner &in)
Definition IOHandlerImpl.cpp:262
IO::readTermProduct
void readTermProduct(Scanner &in, const VarNames &names, vector< mpz_class > &term)
Definition IOHandlerImpl.cpp:108
IO::writeTermProduct
void writeTermProduct(const Term &term, const TermTranslator &translator, FILE *out)
Definition IOHandlerImpl.cpp:170