Frobby  0.9.5
IOHandlerImpl.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 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 IO_HANDLER_IMPL_GUARD
18 #define IO_HANDLER_IMPL_GUARD
19 
20 #include "IOHandler.h"
21 #include <vector>
22 
23 class Term;
24 class Scanner;
25 class BigIdeal;
26 class VarNames;
27 class BigTermConsumer;
28 class DataType;
30 class SatBinomConsumer;
31 class TermTranslator;
32 class BigPolynomial;
33 
34 namespace IO {
37  class IOHandlerImpl : public IOHandler {
38  protected:
39  IOHandlerImpl(const char* formatName,
40  const char* formatDescription);
41 
43  void registerInput(const DataType& type);
44 
46  void registerOutput(const DataType& type);
47 
48  private:
49  // The following methods have implementations that merely report
50  // an internal error. Make sure to override those you register
51  // support for.
52  virtual BigTermConsumer* doCreateIdealWriter(FILE* out) = 0;
54 
55  virtual void doReadTerm(Scanner& in, InputConsumer& term);
56  virtual void doReadIdeal(Scanner& in, InputConsumer& consumer);
57  virtual void doReadIdeals(Scanner& in, InputConsumer& consumer);
58  virtual void doReadPolynomial(Scanner& in, CoefBigTermConsumer& consumer);
59  virtual void doReadSatBinomIdeal(Scanner& in, SatBinomConsumer& consumer);
60 
61  // The following methods are implemented with the suggested
62  // behavior
63  virtual const char* doGetName() const;
64  virtual const char* doGetDescription() const;
65  virtual bool doSupportsInput(const DataType& type) const;
66  virtual bool doSupportsOutput(const DataType& type) const;
67  virtual bool doHasMoreInput(Scanner& in) const;
68 
69  vector<const DataType*> _supportedInputs;
70  vector<const DataType*> _supportedOutputs;
71 
72  const char* _formatName;
73  const char* _formatDescription;
74  };
75 
76  void writeCoefTermProduct(const mpz_class& coef,
77  const Term& term,
78  const TermTranslator& translator,
79  bool hidePlus,
80  FILE* out);
81 
82  void writeCoefTermProduct(const mpz_class& coef,
83  const vector<mpz_class>& term,
84  const VarNames& names,
85  bool hidePlus,
86  FILE* out);
87 
88  void writeTermProduct(const Term& term,
89  const TermTranslator& translator,
90  FILE* out);
91 
92  void writeTermProduct(const vector<mpz_class>& term,
93  const VarNames& names,
94  FILE* out);
95 
96  void readTermProduct(Scanner& in,
97  const VarNames& names,
98  vector<mpz_class>& term);
99  void readTermProduct(BigIdeal& ideal, Scanner& in);
100 
101  void readCoefTerm(BigPolynomial& polynomial,
102  bool firstTerm,
103  Scanner& in);
104 
105  void readCoefTerm(mpz_class& coef,
106  vector<mpz_class>& term,
107  const VarNames& names,
108  bool firstTerm,
109  Scanner& in);
110 
111  void readVarPower(vector<mpz_class>& term,
112  const VarNames& names,
113  Scanner& in);
114 }
115 
116 #endif
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
Definition: DataType.h:29
An IOHandler implements input and output for some format in such a way that client code does not need...
Definition: IOHandler.h:41
This class contains a minimum level of functionality that makes it more convenient to derive from tha...
Definition: IOHandlerImpl.h:37
void registerInput(const DataType &type)
Specify that input of the argument type is supported.
virtual void doReadTerm(Scanner &in, InputConsumer &term)
virtual void doReadSatBinomIdeal(Scanner &in, SatBinomConsumer &consumer)
const char * _formatDescription
Definition: IOHandlerImpl.h:73
virtual BigTermConsumer * doCreateIdealWriter(FILE *out)=0
virtual bool doSupportsInput(const DataType &type) const
virtual void doReadIdeal(Scanner &in, InputConsumer &consumer)
virtual const char * doGetDescription() const
virtual const char * doGetName() const
virtual bool doSupportsOutput(const DataType &type) const
IOHandlerImpl(const char *formatName, const char *formatDescription)
virtual bool doHasMoreInput(Scanner &in) const
vector< const DataType * > _supportedOutputs
Definition: IOHandlerImpl.h:70
virtual CoefBigTermConsumer * doCreatePolynomialWriter(FILE *out)
virtual void doReadPolynomial(Scanner &in, CoefBigTermConsumer &consumer)
virtual void doReadIdeals(Scanner &in, InputConsumer &consumer)
void registerOutput(const DataType &type)
Specify that output of the argument type is supported.
const char * _formatName
Definition: IOHandlerImpl.h:72
vector< const DataType * > _supportedInputs
Definition: IOHandlerImpl.h:69
This class offers an input interface which is more convenient and for some purposes more efficient th...
Definition: Scanner.h:50
TermTranslator handles translation between terms whose exponents are infinite precision integers and ...
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
void writeCoefTermProduct(const mpz_class &coef, const Term &term, const TermTranslator &translator, bool hidePlus, FILE *out)
void readVarPower(vector< mpz_class > &term, const VarNames &names, Scanner &in)
void readCoefTerm(BigPolynomial &polynomial, bool firstTerm, Scanner &in)
void readTermProduct(Scanner &in, const VarNames &names, vector< mpz_class > &term)
void writeTermProduct(const Term &term, const TermTranslator &translator, FILE *out)