[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 |
|
---|
[7aa000] | 70 | /****************** Query types Infrastructure **************************/
|
---|
| 71 |
|
---|
| 72 | // Base class
|
---|
[a2ab15] | 73 | Dialog::Query::Query(string _title, string _description) :
|
---|
| 74 | title(_title),
|
---|
| 75 | description(_description)
|
---|
[45f5d6] | 76 | {}
|
---|
[f5a86a] | 77 |
|
---|
[45f5d6] | 78 | Dialog::Query::~Query() {}
|
---|
| 79 |
|
---|
| 80 | const std::string Dialog::Query::getTitle() const{
|
---|
| 81 | return title;
|
---|
[f5a86a] | 82 | }
|
---|
| 83 |
|
---|
[a2ab15] | 84 | const std::string Dialog::Query::getDescription() const{
|
---|
| 85 | return description;
|
---|
| 86 | }
|
---|
[86466e] | 87 | // empty Queries
|
---|
| 88 |
|
---|
| 89 | Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
|
---|
| 90 | Query(title, description)
|
---|
| 91 | {}
|
---|
| 92 |
|
---|
| 93 | Dialog::EmptyQuery::~EmptyQuery() {}
|
---|
| 94 |
|
---|
| 95 | void Dialog::EmptyQuery::setResult() {
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[7aa000] | 98 | // Int Queries
|
---|
| 99 |
|
---|
[75dc28] | 100 | Dialog::IntQuery::IntQuery(string title, std::string description) :
|
---|
| 101 | Query(title, description)
|
---|
[45f5d6] | 102 | {}
|
---|
| 103 |
|
---|
| 104 | Dialog::IntQuery::~IntQuery() {}
|
---|
| 105 |
|
---|
| 106 | void Dialog::IntQuery::setResult() {
|
---|
[3731b4] | 107 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[f5a86a] | 108 | }
|
---|
[45f5d6] | 109 |
|
---|
[7cd6e7] | 110 | // Ints Queries
|
---|
| 111 |
|
---|
| 112 | Dialog::IntsQuery::IntsQuery(string title, std::string description) :
|
---|
| 113 | Query(title, description)
|
---|
| 114 | {}
|
---|
| 115 |
|
---|
| 116 | Dialog::IntsQuery::~IntsQuery() {}
|
---|
| 117 |
|
---|
| 118 | void Dialog::IntsQuery::setResult() {
|
---|
| 119 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | // Bool Queries
|
---|
[97ebf8] | 123 |
|
---|
[75dc28] | 124 | Dialog::BooleanQuery::BooleanQuery(string title,std::string description) :
|
---|
| 125 | Query(title, description)
|
---|
[97ebf8] | 126 | {}
|
---|
| 127 |
|
---|
| 128 | Dialog::BooleanQuery::~BooleanQuery() {}
|
---|
| 129 |
|
---|
| 130 | void Dialog::BooleanQuery::setResult() {
|
---|
[3731b4] | 131 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[97ebf8] | 132 | }
|
---|
| 133 |
|
---|
[7aa000] | 134 | // String Queries
|
---|
| 135 |
|
---|
[75dc28] | 136 | Dialog::StringQuery::StringQuery(string title,std::string _description) :
|
---|
| 137 | Query(title, _description)
|
---|
[45f5d6] | 138 | {}
|
---|
| 139 |
|
---|
| 140 | Dialog::StringQuery::~StringQuery() {};
|
---|
| 141 |
|
---|
| 142 | void Dialog::StringQuery::setResult() {
|
---|
[3731b4] | 143 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[45f5d6] | 144 | }
|
---|
| 145 |
|
---|
[cd8e55] | 146 | // Strings Queries
|
---|
| 147 |
|
---|
[75dc28] | 148 | Dialog::StringsQuery::StringsQuery(string title,std::string _description) :
|
---|
| 149 | Query(title, _description)
|
---|
[cd8e55] | 150 | {}
|
---|
| 151 |
|
---|
| 152 | Dialog::StringsQuery::~StringsQuery() {};
|
---|
| 153 |
|
---|
| 154 | void Dialog::StringsQuery::setResult() {
|
---|
[3731b4] | 155 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[cd8e55] | 156 | }
|
---|
| 157 |
|
---|
[2ededc2] | 158 | // Double Queries
|
---|
| 159 |
|
---|
[75dc28] | 160 | Dialog::DoubleQuery::DoubleQuery(string title, std::string _description) :
|
---|
| 161 | Query(title, _description)
|
---|
[2ededc2] | 162 | {}
|
---|
| 163 |
|
---|
| 164 | Dialog::DoubleQuery::~DoubleQuery() {};
|
---|
| 165 |
|
---|
| 166 | void Dialog::DoubleQuery::setResult() {
|
---|
[3731b4] | 167 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[2ededc2] | 168 | }
|
---|
| 169 |
|
---|
[7cd6e7] | 170 | // Doubles Queries
|
---|
| 171 |
|
---|
| 172 | Dialog::DoublesQuery::DoublesQuery(string title, std::string _description) :
|
---|
| 173 | Query(title, _description)
|
---|
| 174 | {}
|
---|
| 175 |
|
---|
| 176 | Dialog::DoublesQuery::~DoublesQuery() {};
|
---|
| 177 |
|
---|
| 178 | void Dialog::DoublesQuery::setResult() {
|
---|
| 179 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
| 180 | }
|
---|
| 181 |
|
---|
[2ededc2] | 182 |
|
---|
[97ebf8] | 183 | // Atom Queries
|
---|
| 184 |
|
---|
[75dc28] | 185 | Dialog::AtomQuery::AtomQuery(string title, std::string _description) :
|
---|
[97ebf8] | 186 | Query(title, _description),
|
---|
[75dc28] | 187 | tmp(0)
|
---|
[97ebf8] | 188 | {}
|
---|
| 189 |
|
---|
| 190 | Dialog::AtomQuery::~AtomQuery() {}
|
---|
| 191 |
|
---|
| 192 | void Dialog::AtomQuery::setResult() {
|
---|
[3731b4] | 193 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[97ebf8] | 194 | }
|
---|
| 195 |
|
---|
[7cd6e7] | 196 | // Atoms Queries
|
---|
| 197 |
|
---|
| 198 | Dialog::AtomsQuery::AtomsQuery(string title, std::string _description) :
|
---|
| 199 | Query(title, _description),
|
---|
| 200 | tmp(0)
|
---|
| 201 | {}
|
---|
| 202 |
|
---|
| 203 | Dialog::AtomsQuery::~AtomsQuery() {}
|
---|
| 204 |
|
---|
| 205 | void Dialog::AtomsQuery::setResult() {
|
---|
| 206 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[7aa000] | 209 | // Molecule Queries
|
---|
| 210 |
|
---|
[75dc28] | 211 | Dialog::MoleculeQuery::MoleculeQuery(string title, std::string _description) :
|
---|
[a2ab15] | 212 | Query(title, _description),
|
---|
[75dc28] | 213 | tmp(0)
|
---|
[7aa000] | 214 | {}
|
---|
| 215 |
|
---|
| 216 | Dialog::MoleculeQuery::~MoleculeQuery() {}
|
---|
| 217 |
|
---|
| 218 | void Dialog::MoleculeQuery::setResult() {
|
---|
[3731b4] | 219 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[7aa000] | 220 | }
|
---|
[2ededc2] | 221 |
|
---|
[7cd6e7] | 222 | // Molecules Queries
|
---|
| 223 |
|
---|
| 224 | Dialog::MoleculesQuery::MoleculesQuery(string title, std::string _description) :
|
---|
| 225 | Query(title, _description),
|
---|
| 226 | tmp(0)
|
---|
| 227 | {}
|
---|
| 228 |
|
---|
| 229 | Dialog::MoleculesQuery::~MoleculesQuery() {}
|
---|
| 230 |
|
---|
| 231 | void Dialog::MoleculesQuery::setResult() {
|
---|
| 232 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
| 233 | }
|
---|
| 234 |
|
---|
[2ededc2] | 235 | // Vector Queries
|
---|
| 236 |
|
---|
[75dc28] | 237 | Dialog::VectorQuery::VectorQuery(std::string title,bool _check, std::string _description) :
|
---|
[a2ab15] | 238 | Query(title, _description),
|
---|
[75dc28] | 239 | check(_check)
|
---|
[7cd6e7] | 240 | {}
|
---|
[2ededc2] | 241 |
|
---|
| 242 | Dialog::VectorQuery::~VectorQuery()
|
---|
[7cd6e7] | 243 | {}
|
---|
[2ededc2] | 244 |
|
---|
| 245 | void Dialog::VectorQuery::setResult() {
|
---|
[3731b4] | 246 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[2ededc2] | 247 | }
|
---|
[5a7243] | 248 |
|
---|
[7cd6e7] | 249 | // Vectors Queries
|
---|
| 250 |
|
---|
| 251 | Dialog::VectorsQuery::VectorsQuery(std::string title,bool _check, std::string _description) :
|
---|
| 252 | Query(title, _description),
|
---|
| 253 | check(_check)
|
---|
| 254 | {}
|
---|
| 255 |
|
---|
| 256 | Dialog::VectorsQuery::~VectorsQuery()
|
---|
| 257 | {}
|
---|
| 258 |
|
---|
| 259 | void Dialog::VectorsQuery::setResult() {
|
---|
| 260 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
| 261 | }
|
---|
| 262 |
|
---|
[97ebf8] | 263 | // Box Queries
|
---|
| 264 |
|
---|
[75dc28] | 265 | Dialog::BoxQuery::BoxQuery(std::string title, std::string _description) :
|
---|
| 266 | Query(title, _description)
|
---|
[8bc733] | 267 | {}
|
---|
[97ebf8] | 268 |
|
---|
| 269 | Dialog::BoxQuery::~BoxQuery()
|
---|
[8bc733] | 270 | {}
|
---|
[97ebf8] | 271 |
|
---|
| 272 | void Dialog::BoxQuery::setResult() {
|
---|
[3731b4] | 273 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[97ebf8] | 274 | }
|
---|
| 275 |
|
---|
[5a7243] | 276 | // Element Queries
|
---|
[75dc28] | 277 | Dialog::ElementQuery::ElementQuery(std::string title, std::string _description) :
|
---|
| 278 | Query(title, _description)
|
---|
[5a7243] | 279 | {}
|
---|
| 280 |
|
---|
| 281 | Dialog::ElementQuery::~ElementQuery(){}
|
---|
| 282 |
|
---|
| 283 | void Dialog::ElementQuery::setResult(){
|
---|
[3731b4] | 284 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
[5a7243] | 285 | }
|
---|
[7cd6e7] | 286 |
|
---|
| 287 | // Elements Queries
|
---|
| 288 | Dialog::ElementsQuery::ElementsQuery(std::string title, std::string _description) :
|
---|
| 289 | Query(title, _description)
|
---|
| 290 | {}
|
---|
| 291 |
|
---|
| 292 | Dialog::ElementsQuery::~ElementsQuery(){}
|
---|
| 293 |
|
---|
| 294 | void Dialog::ElementsQuery::setResult(){
|
---|
| 295 | ValueStorage::getInstance().setCurrentValue(title.c_str(), tmp);
|
---|
| 296 | }
|
---|