this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 * Main authors:
4 * Guido Tack <tack@gecode.org>
5 *
6 * Copyright:
7 * Guido Tack, 2006
8 *
9 * This file is part of Gecode, the generic constraint
10 * development environment:
11 * http://www.gecode.org
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this software and associated documentation files (the
15 * "Software"), to deal in the Software without restriction, including
16 * without limitation the rights to use, copy, modify, merge, publish,
17 * distribute, sublicense, and/or sell copies of the Software, and to
18 * permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be
22 * included in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 *
32 */
33
34#include <cstdlib>
35#include <QtGui>
36
37#include <gecode/gist.hh>
38#include <gecode/gist/textoutput.hh>
39#include <gecode/gist/mainwindow.hh>
40#include <gecode/gist/stopbrancher.hh>
41
42namespace Gecode { namespace Gist {
43
44 std::string
45 Inspector::name(void) { return "Inspector"; }
46
47 void
48 Inspector::finalize(void) {}
49
50 Inspector::~Inspector(void) {}
51
52 std::string
53 Comparator::name(void) { return "Comparator"; }
54
55 void
56 Comparator::finalize(void) {}
57
58 Comparator::~Comparator(void) {}
59
60 TextOutput::TextOutput(const std::string& name)
61 : t(nullptr), n(name) {}
62
63 void
64 TextOutput::finalize(void) {
65 delete t;
66 t = nullptr;
67 }
68
69 TextOutput::~TextOutput(void) {
70 delete t;
71 }
72
73 std::string
74 TextOutput::name(void) { return n; }
75
76 void
77 TextOutput::init(void) {
78 if (t == nullptr) {
79 t = new TextOutputI(n);
80 }
81 t->setVisible(true);
82 }
83
84 std::ostream&
85 TextOutput::getStream(void) {
86 return t->getStream();
87 }
88
89 void
90 TextOutput::flush(void) {
91 t->flush();
92 }
93
94 void
95 TextOutput::addHtml(const char* s) {
96 t->insertHtml(s);
97 }
98
99 const Options Options::def;
100
101 int
102 explore(Space* root, bool bab, const Options& opt) {
103
104#ifdef _MSC_VER
105 // Set the plugin search path on Windows when in default installation
106 if (char* gd = getenv("GECODEDIR")) {
107 unsigned int gdl = static_cast<unsigned int>(strlen(gd) + 32U);
108 char* gdb = heap.alloc<char>(gdl);
109 strcpy(gdb, gd);
110 strcat(gdb, "/bin/");
111 QCoreApplication::addLibraryPath(gdb);
112 heap.free(gdb,gdl);
113 }
114#endif
115
116 char argv0='\0'; char* argv1=&argv0;
117 int argc=0;
118
119
120 QApplication app(argc, &argv1);
121
122 GistMainWindow mw(root, bab, opt);
123 return app.exec();
124 }
125
126 void
127 stopBranch(Space& home) {
128 StopBrancher::post(home);
129 }
130
131}}
132
133// STATISTICS: gist-any