#include "ppl_test.hh" #include #include #include #include using namespace std; using namespace Parma_Polyhedra_Library; using namespace Parma_Polyhedra_Library::IO_Operators; map var_to_print; map::iterator iter; void my_output_function(ostream& s, const Variable v) { //s << "x" << v.id(); iter = var_to_print.find(v.id()); s << iter->second; } void myprint_constraints(const ConSys& cs, const string& intro, ostream& s){ using namespace IO_Operators; //Save the default output function. Variable::Output_Function_Type* p_default_output_function = Variable::get_output_function(); // Install an alternate output function. Variable::set_output_function(my_output_function); if (!intro.empty()) s << intro << endl; ConSys::const_iterator i = cs.begin(); ConSys::const_iterator cs_end = cs.end(); bool printed_something = i != cs_end; while (i != cs_end) { s << *i++; if (i != cs_end) s << "," << endl; } s << (printed_something ? "." : "true.") << endl; Variable::set_output_function(p_default_output_function); } int main() { var_to_print.insert(pair< dimension_type,string>(0, "var_fst")); var_to_print.insert(pair< dimension_type,string>(1, "var_snd")); var_to_print.insert(pair< dimension_type,string>(2, "var_trd")); Variable a(0); Variable b(1); Variable c(2); C_Polyhedron ph(3); ph.add_constraint(a == 1); ph.add_constraint(b >= 1); myprint_constraints(ph.constraints(),"poliedro",cout); ph.add_constraint(c == a + 3); myprint_constraints(ph.constraints(),"poliedro",cout); /* // Check that the installation worked as expected. if (Variable::get_output_function() != my_output_function) return 1; // Restore the default output function. Variable::set_output_function(p_default_output_function); // Check that the restoration worked as expected. if (Variable::get_output_function() != p_default_output_function) return 1; */ return 0; }