/*
* Project: MoleCuilder
* Description: creates and alters molecular systems
* Copyright (C) 2010-2012 University of Bonn. All rights reserved.
*
*
* This file is part of MoleCuilder.
*
* MoleCuilder is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MoleCuilder is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MoleCuilder. If not, see .
*/
/*
* 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 "CodePatterns/Log.hpp"
#include "CodePatterns/Verbose.hpp"
#include "Parameters/ParameterExceptions.hpp"
class Atom;
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(){
handleAll();
setAll();
return true;
// if(checkAll()){
// setAll();
// return true;
// }
// else{
// return false;
// }
}
void Dialog::handleAll(){
list::iterator iter;
for(iter=queries.begin(); iter!=queries.end(); iter++){
try{
(*iter)->handle();
}catch(...){
// if any query fails (is canceled), we can end the handling process
ELOG(1, "The following query failed: " << (**iter).getTitle() << ".");
break;
}
}
}
bool Dialog::checkAll(){
list::iterator iter;
bool retval = true;
for(iter=queries.begin(); iter!=queries.end(); iter++){
retval &= (*iter)->isValid();
// 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++) {
// try {
(*iter)->setResult();
// } catch (ParameterException &e) {
// if( const std::string *name=boost::get_error_info(e) )
// ELOG(1, "The following parameter value is not valid: " << *name << ".");
// break;
// }
}
}
bool Dialog::hasQueries(){
return queries.size();
}
/*template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryEmpty(param, title, description);
}*/
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryBoolean(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryInt(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryInts(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryUnsignedInt(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryUnsignedInts(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryDouble(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryDoubles(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryString(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryStrings(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryAtom(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryAtoms(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryMolecule(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryMolecules(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryVector(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryVectors(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryRealSpaceMatrix(param, title, description);
}
template <> void Dialog::query(Parameter ¶m, const std::string title, const std::string description)
{
queryElement(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryElements(param, title, description);
}
template <> void Dialog::query< boost::filesystem::path >(Parameter ¶m, const std::string title, const std::string description)
{
queryFile(param, title, description);
}
template <> void Dialog::query< std::vector >(Parameter > ¶m, const std::string title, const std::string description)
{
queryFiles(param, title, description);
}
template <> void Dialog::query< RandomNumberDistribution_Parameters >(Parameter ¶m, const std::string title, const std::string description)
{
queryRandomNumberDistribution_Parameters(param, title, description);
}
/************************** Query Infrastructure ************************/
/* ---> shifted to folder Query */
/************************************************************************/