| [f5a86a] | 1 | /* | 
|---|
|  | 2 | * Dialog.cpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Jan 5, 2010 | 
|---|
|  | 5 | *      Author: crueger | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
| [112b09] | 8 | #include "Helpers/MemDebug.hpp" | 
|---|
|  | 9 |  | 
|---|
| [5079a0] | 10 | #include "Dialog.hpp" | 
|---|
| [75dc28] | 11 | #include "ValueStorage.hpp" | 
|---|
| [f5a86a] | 12 |  | 
|---|
| [36166d] | 13 | #include "verbose.hpp" | 
|---|
| [97ebf8] | 14 | #include "atom.hpp" | 
|---|
|  | 15 | #include "element.hpp" | 
|---|
|  | 16 | #include "molecule.hpp" | 
|---|
| [2ededc2] | 17 | #include "vector.hpp" | 
|---|
| [84c494] | 18 | #include "Matrix.hpp" | 
|---|
|  | 19 | #include "Box.hpp" | 
|---|
| [2ededc2] | 20 |  | 
|---|
| [f5a86a] | 21 | using namespace std; | 
|---|
|  | 22 |  | 
|---|
|  | 23 | Dialog::Dialog() | 
|---|
|  | 24 | { | 
|---|
|  | 25 | } | 
|---|
|  | 26 |  | 
|---|
|  | 27 | Dialog::~Dialog() | 
|---|
|  | 28 | { | 
|---|
| [45f5d6] | 29 | list<Query*>::iterator iter; | 
|---|
|  | 30 | for(iter=queries.begin();iter!=queries.end();iter++){ | 
|---|
|  | 31 | delete (*iter); | 
|---|
|  | 32 | } | 
|---|
| [f5a86a] | 33 | } | 
|---|
|  | 34 |  | 
|---|
| [45f5d6] | 35 | void Dialog::registerQuery(Query *query){ | 
|---|
|  | 36 | queries.push_back(query); | 
|---|
|  | 37 | } | 
|---|
| [f5a86a] | 38 |  | 
|---|
| [45f5d6] | 39 | bool Dialog::display(){ | 
|---|
| [d3a5ea] | 40 | if(checkAll()){ | 
|---|
|  | 41 | setAll(); | 
|---|
|  | 42 | return true; | 
|---|
|  | 43 | } | 
|---|
|  | 44 | else{ | 
|---|
|  | 45 | return false; | 
|---|
|  | 46 | } | 
|---|
|  | 47 | } | 
|---|
|  | 48 |  | 
|---|
|  | 49 | bool Dialog::checkAll(){ | 
|---|
| [45f5d6] | 50 | list<Query*>::iterator iter; | 
|---|
|  | 51 | bool retval = true; | 
|---|
|  | 52 | for(iter=queries.begin(); iter!=queries.end(); iter++){ | 
|---|
|  | 53 | retval &= (*iter)->handle(); | 
|---|
|  | 54 | // if any query fails (is canceled), we can end the handling process | 
|---|
| [94d131] | 55 | if(!retval) { | 
|---|
|  | 56 | DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl); | 
|---|
| [45f5d6] | 57 | break; | 
|---|
| [94d131] | 58 | } | 
|---|
| [45f5d6] | 59 | } | 
|---|
|  | 60 | return retval; | 
|---|
| [f5a86a] | 61 | } | 
|---|
|  | 62 |  | 
|---|
| [d3a5ea] | 63 | void Dialog::setAll(){ | 
|---|
|  | 64 | list<Query*>::iterator iter; | 
|---|
|  | 65 | for(iter=queries.begin(); iter!=queries.end(); iter++) { | 
|---|
|  | 66 | (*iter)->setResult(); | 
|---|
|  | 67 | } | 
|---|
|  | 68 | } | 
|---|
|  | 69 |  | 
|---|
| [c508ef5] | 70 | bool Dialog::hasQueries(){ | 
|---|
|  | 71 | return queries.size(); | 
|---|
|  | 72 | } | 
|---|
|  | 73 |  | 
|---|
| [7aa000] | 74 | /****************** Query types Infrastructure **************************/ | 
|---|
|  | 75 |  | 
|---|
|  | 76 | // Base class | 
|---|
| [a2ab15] | 77 | Dialog::Query::Query(string _title, string _description) : | 
|---|
|  | 78 | title(_title), | 
|---|
|  | 79 | description(_description) | 
|---|
| [45f5d6] | 80 | {} | 
|---|
| [f5a86a] | 81 |  | 
|---|
| [45f5d6] | 82 | Dialog::Query::~Query() {} | 
|---|
|  | 83 |  | 
|---|
|  | 84 | const std::string Dialog::Query::getTitle() const{ | 
|---|
|  | 85 | return title; | 
|---|
| [f5a86a] | 86 | } | 
|---|
|  | 87 |  | 
|---|
| [a2ab15] | 88 | const std::string Dialog::Query::getDescription() const{ | 
|---|
|  | 89 | return description; | 
|---|
|  | 90 | } | 
|---|
| [86466e] | 91 | // empty Queries | 
|---|
|  | 92 |  | 
|---|
|  | 93 | Dialog::EmptyQuery::EmptyQuery(string title, std::string description) : | 
|---|
|  | 94 | Query(title, description) | 
|---|
|  | 95 | {} | 
|---|
|  | 96 |  | 
|---|
|  | 97 | Dialog::EmptyQuery::~EmptyQuery() {} | 
|---|
|  | 98 |  | 
|---|
|  | 99 | void Dialog::EmptyQuery::setResult() { | 
|---|
|  | 100 | } | 
|---|
|  | 101 |  | 
|---|
| [7aa000] | 102 | // Int Queries | 
|---|
|  | 103 |  | 
|---|
| [75dc28] | 104 | Dialog::IntQuery::IntQuery(string title, std::string description) : | 
|---|
|  | 105 | Query(title, description) | 
|---|
| [45f5d6] | 106 | {} | 
|---|
|  | 107 |  | 
|---|
|  | 108 | Dialog::IntQuery::~IntQuery() {} | 
|---|
|  | 109 |  | 
|---|
|  | 110 | void Dialog::IntQuery::setResult() { | 
|---|
| [3731b4] | 111 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [f5a86a] | 112 | } | 
|---|
| [45f5d6] | 113 |  | 
|---|
| [7cd6e7] | 114 | // Ints Queries | 
|---|
|  | 115 |  | 
|---|
|  | 116 | Dialog::IntsQuery::IntsQuery(string title, std::string description) : | 
|---|
|  | 117 | Query(title, description) | 
|---|
|  | 118 | {} | 
|---|
|  | 119 |  | 
|---|
|  | 120 | Dialog::IntsQuery::~IntsQuery() {} | 
|---|
|  | 121 |  | 
|---|
|  | 122 | void Dialog::IntsQuery::setResult() { | 
|---|
|  | 123 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
|  | 124 | } | 
|---|
|  | 125 |  | 
|---|
|  | 126 | // Bool Queries | 
|---|
| [97ebf8] | 127 |  | 
|---|
| [75dc28] | 128 | Dialog::BooleanQuery::BooleanQuery(string title,std::string description) : | 
|---|
|  | 129 | Query(title, description) | 
|---|
| [97ebf8] | 130 | {} | 
|---|
|  | 131 |  | 
|---|
|  | 132 | Dialog::BooleanQuery::~BooleanQuery() {} | 
|---|
|  | 133 |  | 
|---|
|  | 134 | void Dialog::BooleanQuery::setResult() { | 
|---|
| [3731b4] | 135 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [97ebf8] | 136 | } | 
|---|
|  | 137 |  | 
|---|
| [7aa000] | 138 | // String Queries | 
|---|
|  | 139 |  | 
|---|
| [75dc28] | 140 | Dialog::StringQuery::StringQuery(string title,std::string _description) : | 
|---|
|  | 141 | Query(title, _description) | 
|---|
| [45f5d6] | 142 | {} | 
|---|
|  | 143 |  | 
|---|
|  | 144 | Dialog::StringQuery::~StringQuery() {}; | 
|---|
|  | 145 |  | 
|---|
|  | 146 | void Dialog::StringQuery::setResult() { | 
|---|
| [3731b4] | 147 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [45f5d6] | 148 | } | 
|---|
|  | 149 |  | 
|---|
| [cd8e55] | 150 | // Strings Queries | 
|---|
|  | 151 |  | 
|---|
| [75dc28] | 152 | Dialog::StringsQuery::StringsQuery(string title,std::string _description) : | 
|---|
|  | 153 | Query(title, _description) | 
|---|
| [cd8e55] | 154 | {} | 
|---|
|  | 155 |  | 
|---|
|  | 156 | Dialog::StringsQuery::~StringsQuery() {}; | 
|---|
|  | 157 |  | 
|---|
|  | 158 | void Dialog::StringsQuery::setResult() { | 
|---|
| [3731b4] | 159 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [cd8e55] | 160 | } | 
|---|
|  | 161 |  | 
|---|
| [2ededc2] | 162 | // Double Queries | 
|---|
|  | 163 |  | 
|---|
| [75dc28] | 164 | Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) : | 
|---|
|  | 165 | Query(title, _description) | 
|---|
| [2ededc2] | 166 | {} | 
|---|
|  | 167 |  | 
|---|
|  | 168 | Dialog::DoubleQuery::~DoubleQuery() {}; | 
|---|
|  | 169 |  | 
|---|
|  | 170 | void Dialog::DoubleQuery::setResult() { | 
|---|
| [3731b4] | 171 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [2ededc2] | 172 | } | 
|---|
|  | 173 |  | 
|---|
| [7cd6e7] | 174 | // Doubles Queries | 
|---|
|  | 175 |  | 
|---|
|  | 176 | Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) : | 
|---|
|  | 177 | Query(title, _description) | 
|---|
|  | 178 | {} | 
|---|
|  | 179 |  | 
|---|
|  | 180 | Dialog::DoublesQuery::~DoublesQuery() {}; | 
|---|
|  | 181 |  | 
|---|
|  | 182 | void Dialog::DoublesQuery::setResult() { | 
|---|
|  | 183 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
|  | 184 | } | 
|---|
|  | 185 |  | 
|---|
| [2ededc2] | 186 |  | 
|---|
| [97ebf8] | 187 | // Atom Queries | 
|---|
|  | 188 |  | 
|---|
| [75dc28] | 189 | Dialog::AtomQuery::AtomQuery(string title, std::string _description) : | 
|---|
| [97ebf8] | 190 | Query(title, _description), | 
|---|
| [75dc28] | 191 | tmp(0) | 
|---|
| [97ebf8] | 192 | {} | 
|---|
|  | 193 |  | 
|---|
|  | 194 | Dialog::AtomQuery::~AtomQuery() {} | 
|---|
|  | 195 |  | 
|---|
|  | 196 | void Dialog::AtomQuery::setResult() { | 
|---|
| [3731b4] | 197 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [97ebf8] | 198 | } | 
|---|
|  | 199 |  | 
|---|
| [7cd6e7] | 200 | // Atoms Queries | 
|---|
|  | 201 |  | 
|---|
|  | 202 | Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) : | 
|---|
|  | 203 | Query(title, _description), | 
|---|
|  | 204 | tmp(0) | 
|---|
|  | 205 | {} | 
|---|
|  | 206 |  | 
|---|
|  | 207 | Dialog::AtomsQuery::~AtomsQuery() {} | 
|---|
|  | 208 |  | 
|---|
|  | 209 | void Dialog::AtomsQuery::setResult() { | 
|---|
|  | 210 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
|  | 211 | } | 
|---|
|  | 212 |  | 
|---|
| [7aa000] | 213 | // Molecule Queries | 
|---|
|  | 214 |  | 
|---|
| [75dc28] | 215 | Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) : | 
|---|
| [a2ab15] | 216 | Query(title, _description), | 
|---|
| [75dc28] | 217 | tmp(0) | 
|---|
| [7aa000] | 218 | {} | 
|---|
|  | 219 |  | 
|---|
|  | 220 | Dialog::MoleculeQuery::~MoleculeQuery() {} | 
|---|
|  | 221 |  | 
|---|
|  | 222 | void Dialog::MoleculeQuery::setResult() { | 
|---|
| [3731b4] | 223 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [7aa000] | 224 | } | 
|---|
| [2ededc2] | 225 |  | 
|---|
| [7cd6e7] | 226 | // Molecules Queries | 
|---|
|  | 227 |  | 
|---|
|  | 228 | Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) : | 
|---|
|  | 229 | Query(title, _description), | 
|---|
|  | 230 | tmp(0) | 
|---|
|  | 231 | {} | 
|---|
|  | 232 |  | 
|---|
|  | 233 | Dialog::MoleculesQuery::~MoleculesQuery() {} | 
|---|
|  | 234 |  | 
|---|
|  | 235 | void Dialog::MoleculesQuery::setResult() { | 
|---|
|  | 236 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
|  | 237 | } | 
|---|
|  | 238 |  | 
|---|
| [2ededc2] | 239 | // Vector Queries | 
|---|
|  | 240 |  | 
|---|
| [75dc28] | 241 | Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) : | 
|---|
| [a2ab15] | 242 | Query(title, _description), | 
|---|
| [75dc28] | 243 | check(_check) | 
|---|
| [7cd6e7] | 244 | {} | 
|---|
| [2ededc2] | 245 |  | 
|---|
|  | 246 | Dialog::VectorQuery::~VectorQuery() | 
|---|
| [7cd6e7] | 247 | {} | 
|---|
| [2ededc2] | 248 |  | 
|---|
|  | 249 | void Dialog::VectorQuery::setResult() { | 
|---|
| [3731b4] | 250 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [2ededc2] | 251 | } | 
|---|
| [5a7243] | 252 |  | 
|---|
| [7cd6e7] | 253 | // Vectors Queries | 
|---|
|  | 254 |  | 
|---|
|  | 255 | Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) : | 
|---|
|  | 256 | Query(title, _description), | 
|---|
|  | 257 | check(_check) | 
|---|
|  | 258 | {} | 
|---|
|  | 259 |  | 
|---|
|  | 260 | Dialog::VectorsQuery::~VectorsQuery() | 
|---|
|  | 261 | {} | 
|---|
|  | 262 |  | 
|---|
|  | 263 | void Dialog::VectorsQuery::setResult() { | 
|---|
|  | 264 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
|  | 265 | } | 
|---|
|  | 266 |  | 
|---|
| [97ebf8] | 267 | // Box Queries | 
|---|
|  | 268 |  | 
|---|
| [75dc28] | 269 | Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) : | 
|---|
|  | 270 | Query(title, _description) | 
|---|
| [8bc733] | 271 | {} | 
|---|
| [97ebf8] | 272 |  | 
|---|
|  | 273 | Dialog::BoxQuery::~BoxQuery() | 
|---|
| [8bc733] | 274 | {} | 
|---|
| [97ebf8] | 275 |  | 
|---|
|  | 276 | void Dialog::BoxQuery::setResult() { | 
|---|
| [3731b4] | 277 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [97ebf8] | 278 | } | 
|---|
|  | 279 |  | 
|---|
| [5a7243] | 280 | // Element Queries | 
|---|
| [75dc28] | 281 | Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) : | 
|---|
|  | 282 | Query(title, _description) | 
|---|
| [5a7243] | 283 | {} | 
|---|
|  | 284 |  | 
|---|
|  | 285 | Dialog::ElementQuery::~ElementQuery(){} | 
|---|
|  | 286 |  | 
|---|
|  | 287 | void Dialog::ElementQuery::setResult(){ | 
|---|
| [3731b4] | 288 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
| [5a7243] | 289 | } | 
|---|
| [7cd6e7] | 290 |  | 
|---|
|  | 291 | // Elements Queries | 
|---|
|  | 292 | Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) : | 
|---|
|  | 293 | Query(title, _description) | 
|---|
|  | 294 | {} | 
|---|
|  | 295 |  | 
|---|
|  | 296 | Dialog::ElementsQuery::~ElementsQuery(){} | 
|---|
|  | 297 |  | 
|---|
|  | 298 | void Dialog::ElementsQuery::setResult(){ | 
|---|
|  | 299 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp); | 
|---|
|  | 300 | } | 
|---|