#include <Poly.h> using namespace polymake;
class Poly : public std::iostream
An object of this class encapsulates a communication channel to the polymake server.
Each channel can be bound to exactly one data file. Therefore, a client program
computing properties of a polyhedron or constructing it from scratch normally needs a single Poly object,
while a client transforming a polyhedron to a new one will need two or more such objects.
argv elements of the main() function.
ios::in |
Data file must exist and is opened read-only: existing properties may be read. |
ios::in | ios::out |
Data file must exist; properties can be read, written, or deleted. |
ios::out |
Data file can exist; new properties can be added. |
ios::out | ios::trunc |
Data file is created empty or truncated to zero length; new properties can be added. |
ios::in | ios::out | ios::trunc |
Data file is created empty or truncated to zero length; new properties can be added, and later read or deleted. |
polymake server.
If the variable POLYMAKE_SWITCHES was already set in
the client's environment, both option sets are merged. But if the client program is itself called by the server via
the rules, opt has no effect.
... variant must be
a zero pointer (0).
std::iostream methods.
PTL defines also constructors and input operators for all top-level PTL container classes,
as well as input operators for the most popular STL containers: std::vector, std::list,
std_ext::hash_set,
and std_ext::hash_map.
read() calls, each next call "forgets" the properties requested by the
previous one and makes the input stream empty before new data arrive.
"") signals
that the server could not create the requested property (due to lacking data, failed rules, etc.)
or that there exists a negated property contradicting the requested one.
int, double, or Rational, are treated as having dimension 0.
read() call has contained more than one request.
After the data of a property are completely read in, the input stream switches to the eof()
state, so that any further attempts to read anything will fail. next() makes the data of the
next input property free and clears the eof() state.
... variant must be
a zero pointer (0).
std::ostream methods. PTL defines also output operators for all
top-level PTL container classes, as well as for the most popular STL containers:
std::vector, std::list, std_ext::hash_set,
and std_ext::hash_map.
endl.)
The number of empty lines written out must exactly match the number of arguments in the prior
write call. The check is made in every but the first write call, as well as in each
commit call.
read and write operations don't interfere each other. Unlike in
the standard file-oriented IO, the input and output data streams are fully independent.
... variant must be
a zero pointer (0).
read and write streams, unless you are trying
to delete just the same property that you have requested to read former.
The data exchange between the server and the client runs under transaction control: all changes made by the client remain tentative unless committed explicitly. A communication error of any kind reverts the data file to the last permanent state: either immediately before the client has started, or after the last successful commitment, if any.
Poly object is any other than good(),
this call is equivalent to rollback().
Poly destructor calls always commit, so that this method is really needed only
if the client perfroms complex, multi-step operations.
commit or client start.
There are two kinds of error conditions that can arise during the lifetime of a Poly object.
The first are those inherent to all input/output streams, such as a non-existing file name, or
a parse error in the input data. They are reported via the standard ios::setstate() method.
You can check them either using standard methods good(), fail(), etc,
or let the object raise an exception std::iostream::failure
using the exceptions() method. Note that the constructors of PTL
container classes also raise this exception if they can't parse the input data.
The second kind are errors specific to the communication with the polymake server. They are signaled by throwing an exception of one of the following types.
write, commit, and Poly destructor if there are pending
output properties (that is, less sections have been written out than announced in the last write call).
Is raised after std::endl if more properties have been written out than announced.
write while the Poly object was opened read-only.
It's always a programming error.