/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010-2012 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * Dialog.cpp * * Created on: Jan 5, 2010 * Author: crueger */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "Dialog.hpp" #include "Actions/ValueStorage.hpp" #include "CodePatterns/Log.hpp" #include "CodePatterns/Verbose.hpp" class Atom; class Box; class element; class RealSpaceMatrix; class molecule; class Vector; using namespace std; Dialog::Dialog() { } Dialog::~Dialog() { list::iterator iter; for(iter=queries.begin();iter!=queries.end();iter++){ delete (*iter); } } void Dialog::registerQuery(Query *query){ queries.push_back(query); } bool Dialog::display(){ if(checkAll()){ setAll(); return true; } else{ return false; } } bool Dialog::checkAll(){ list::iterator iter; bool retval = true; for(iter=queries.begin(); iter!=queries.end(); iter++){ retval &= (*iter)->handle(); // if any query fails (is canceled), we can end the handling process if(!retval) { ELOG(1, "The following query failed: " << (**iter).getTitle() << "."); break; } } return retval; } void Dialog::setAll(){ list::iterator iter; for(iter=queries.begin(); iter!=queries.end(); iter++) { (*iter)->setResult(); } } bool Dialog::hasQueries(){ return queries.size(); } template <> void Dialog::query(const char *token, std::string description) { queryEmpty(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryBoolean(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryInt(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryInts(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryUnsignedInt(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryUnsignedInts(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryDouble(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryDoubles(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryString(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryStrings(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryAtom(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryAtoms(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryMolecule(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryMolecules(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryVector(token, false, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryVectors(token, false, description); } template <> void Dialog::query(const char *token, std::string description) { queryVector(token, true, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryVectors(token, true, description); } template <> void Dialog::query(const char *token, std::string description) { queryBox(token, description); } template <> void Dialog::query(const char *token, std::string description) { queryElement(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryElements(token, description); } template <> void Dialog::query< boost::filesystem::path >(const char *token, std::string description) { queryFile(token, description); } template <> void Dialog::query< std::vector >(const char *token, std::string description) { queryFiles(token, description); } template <> void Dialog::query< RandomNumberDistribution_Parameters >(const char *token, std::string description) { queryRandomNumberDistribution_Parameters(token, description); } /************************** Query Infrastructure ************************/ /* ---> shifted to folder Query */ /************************************************************************/