Generated on Fri Oct 19 11:24:59 2018 for Gecode by doxygen 1.6.3

gist.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2006
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  * Permission is hereby granted, free of charge, to any person obtaining
00014  * a copy of this software and associated documentation files (the
00015  * "Software"), to deal in the Software without restriction, including
00016  * without limitation the rights to use, copy, modify, merge, publish,
00017  * distribute, sublicense, and/or sell copies of the Software, and to
00018  * permit persons to whom the Software is furnished to do so, subject to
00019  * the following conditions:
00020  *
00021  * The above copyright notice and this permission notice shall be
00022  * included in all copies or substantial portions of the Software.
00023  *
00024  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #include <cstdlib>
00035 #include <QtGui>
00036 
00037 #include <gecode/gist.hh>
00038 #include <gecode/gist/textoutput.hh>
00039 #include <gecode/gist/mainwindow.hh>
00040 #include <gecode/gist/stopbrancher.hh>
00041 
00042 namespace Gecode { namespace Gist {
00043 
00044   std::string
00045   Inspector::name(void) { return "Inspector"; }
00046 
00047   void
00048   Inspector::finalize(void) {}
00049 
00050   Inspector::~Inspector(void) {}
00051 
00052   std::string
00053   Comparator::name(void) { return "Comparator"; }
00054 
00055   void
00056   Comparator::finalize(void) {}
00057 
00058   Comparator::~Comparator(void) {}
00059 
00060   TextOutput::TextOutput(const std::string& name)
00061     : t(NULL), n(name) {}
00062 
00063   void
00064   TextOutput::finalize(void) {
00065     delete t;
00066     t = NULL;
00067   }
00068 
00069   TextOutput::~TextOutput(void) {
00070     delete t;
00071   }
00072 
00073   std::string
00074   TextOutput::name(void) { return n; }
00075 
00076   void
00077   TextOutput::init(void) {
00078     if (t == NULL) {
00079       t = new TextOutputI(n);
00080     }
00081     t->setVisible(true);
00082   }
00083 
00084   std::ostream&
00085   TextOutput::getStream(void) {
00086     return t->getStream();
00087   }
00088 
00089   void
00090   TextOutput::flush(void) {
00091     t->flush();
00092   }
00093 
00094   void
00095   TextOutput::addHtml(const char* s) {
00096     t->insertHtml(s);
00097   }
00098 
00099   const Options Options::def;
00100 
00101   int
00102   explore(Space* root, bool bab, const Options& opt) {
00103 
00104 #ifdef _MSC_VER
00105     // Set the plugin search path on Windows when in default installation
00106     if (char* gd = getenv("GECODEDIR")) {
00107       unsigned int gdl = static_cast<unsigned int>(strlen(gd) + 32U);
00108       char* gdb = heap.alloc<char>(gdl);
00109       strcpy(gdb, gd);
00110       strcat(gdb, "/bin/");
00111       QCoreApplication::addLibraryPath(gdb);
00112       heap.free(gdb,gdl);
00113     }
00114 #endif
00115 
00116     char argv0='\0'; char* argv1=&argv0;
00117     int argc=0;
00118 
00119 
00120     QApplication app(argc, &argv1);
00121 
00122     GistMainWindow mw(root, bab, opt);
00123     return app.exec();
00124   }
00125 
00126   void
00127   stopBranch(Space& home) {
00128     StopBrancher::post(home);
00129   }
00130 
00131 }}
00132 
00133 // STATISTICS: gist-any