Frobby 0.10.0
Loading...
Searching...
No Matches
IOHandlerImpl.h
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
23class Term;
24class Scanner;
25class BigIdeal;
26class VarNames;
27class BigTermConsumer;
28class DataType;
31class TermTranslator;
32class BigPolynomial;
33
34namespace 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;
53 virtual CoefBigTermConsumer* doCreatePolynomialWriter(FILE* out);
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
Definition BigIdeal.h:27
Definition BigPolynomial.h:27
Definition BigTermConsumer.h:29
Definition CoefBigTermConsumer.h:29
Definition DataType.h:29
Definition IOHandler.h:41
void registerInput(const DataType &type)
Definition IOHandlerImpl.cpp:60
void registerOutput(const DataType &type)
Definition IOHandlerImpl.cpp:67
Definition InputConsumer.h:30
Definition SatBinomConsumer.h:25
Definition Scanner.h:50
Definition TermTranslator.h:41
Definition Term.h:49
Definition VarNames.h:38