00001 /* 00002 * Copyright 2007 Martin von Gagern 00003 * 00004 * 00005 * This file is part of bande. 00006 * 00007 * bande is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * bande is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 00022 /** 00023 * @file 00024 * Interface of class bande::Solutions. 00025 */ 00026 00027 namespace bande { 00028 00029 /** 00030 * Handle solutions once they are found. 00031 */ 00032 class Solutions { 00033 public: 00034 00035 /** 00036 * Constructor. 00037 */ 00038 Solutions() : out(&std::cout), ownOut(false) { } 00039 00040 /** 00041 * Destructor. 00042 */ 00043 virtual ~Solutions() { clearOut(); } 00044 00045 /** 00046 * Write all future solutions to the specified file. 00047 * @param file the file to which solutions will be written. 00048 */ 00049 void writeToFile(const std::string& file) { writeToFile(file.c_str()); } 00050 00051 void writeToFile(const char* file); 00052 00053 void writeToStream(std::ostream& outStream); 00054 00055 void solution(const IntegerProgram& ip); 00056 00057 private: 00058 00059 /** 00060 * Pointer to the stream to which solutions are written. 00061 */ 00062 std::ostream* out; 00063 00064 /** 00065 * Indicates own was created by this object. 00066 * 00067 * If this is the case, then we should take care of its eventual 00068 * destruction as well. 00069 */ 00070 bool ownOut; 00071 00072 void writeSolution(const IntegerProgram& ip); 00073 00074 void clearOut(); 00075 }; 00076 00077 }
1.6.0