| 1 | /* | 
|---|
| 2 | * Project: MoleCuilder | 
|---|
| 3 | * Description: creates and alters molecular systems | 
|---|
| 4 | * Copyright (C)  2012 University of Bonn. All rights reserved. | 
|---|
| 5 | * | 
|---|
| 6 | * | 
|---|
| 7 | *   This file is part of MoleCuilder. | 
|---|
| 8 | * | 
|---|
| 9 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
| 10 | *    it under the terms of the GNU General Public License as published by | 
|---|
| 11 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
| 12 | *    (at your option) any later version. | 
|---|
| 13 | * | 
|---|
| 14 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
| 15 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 16 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 17 | *    GNU General Public License for more details. | 
|---|
| 18 | * | 
|---|
| 19 | *    You should have received a copy of the GNU General Public License | 
|---|
| 20 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| 21 | */ | 
|---|
| 22 |  | 
|---|
| 23 | /* | 
|---|
| 24 | * RandomNumberValidators.cpp | 
|---|
| 25 | * | 
|---|
| 26 | *  Created on: May 14, 2012 | 
|---|
| 27 | *      Author: ankele | 
|---|
| 28 | */ | 
|---|
| 29 |  | 
|---|
| 30 |  | 
|---|
| 31 | // include config.h | 
|---|
| 32 | #ifdef HAVE_CONFIG_H | 
|---|
| 33 | #include <config.h> | 
|---|
| 34 | #endif | 
|---|
| 35 |  | 
|---|
| 36 | #include "CodePatterns/MemDebug.hpp" | 
|---|
| 37 |  | 
|---|
| 38 | #include "RandomNumberValidators.hpp" | 
|---|
| 39 |  | 
|---|
| 40 | #include "RandomNumbers/RandomNumberDistributionFactory.hpp" | 
|---|
| 41 | #include "RandomNumbers/RandomNumberEngineFactory.hpp" | 
|---|
| 42 |  | 
|---|
| 43 | bool RandomNumberDistributionNameValidator::isValid(const std::string & _value) const | 
|---|
| 44 | { | 
|---|
| 45 | RandomNumberDistributionFactory::getInstance(); | 
|---|
| 46 | for (RandomNumberDistributionFactory::NameMap::const_iterator | 
|---|
| 47 | iter = RandomNumberDistributionFactory::getInstance().names.begin(); | 
|---|
| 48 | iter != RandomNumberDistributionFactory::getInstance().names.end(); | 
|---|
| 49 | ++iter) { | 
|---|
| 50 | if (_value == iter->second) | 
|---|
| 51 | return true; | 
|---|
| 52 | } | 
|---|
| 53 | return false; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | bool RandomNumberDistributionNameValidator::operator==(const Validator<std::string> &_instance) const | 
|---|
| 57 | { | 
|---|
| 58 | const RandomNumberDistributionNameValidator *inst = | 
|---|
| 59 | dynamic_cast<const RandomNumberDistributionNameValidator *>(&_instance); | 
|---|
| 60 | if (inst) | 
|---|
| 61 | return true; | 
|---|
| 62 | else | 
|---|
| 63 | return false; | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | Validator< std::string >* RandomNumberDistributionNameValidator::clone() const | 
|---|
| 67 | { | 
|---|
| 68 | Validator< std::string > *inst = | 
|---|
| 69 | new RandomNumberDistributionNameValidator(); | 
|---|
| 70 | return inst; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 |  | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 |  | 
|---|
| 77 |  | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 |  | 
|---|
| 81 | bool RandomNumberEngineNameValidator::isValid(const std::string & _value) const | 
|---|
| 82 | { | 
|---|
| 83 | RandomNumberEngineFactory::getInstance(); | 
|---|
| 84 | for (RandomNumberEngineFactory::NameMap::const_iterator | 
|---|
| 85 | iter = RandomNumberEngineFactory::getInstance().names.begin(); | 
|---|
| 86 | iter != RandomNumberEngineFactory::getInstance().names.end(); | 
|---|
| 87 | ++iter) { | 
|---|
| 88 | if (iter->second == _value) | 
|---|
| 89 | return true; | 
|---|
| 90 | } | 
|---|
| 91 | return false; | 
|---|
| 92 | } | 
|---|
| 93 |  | 
|---|
| 94 | bool RandomNumberEngineNameValidator::operator==(const Validator<std::string> &_instance) const | 
|---|
| 95 | { | 
|---|
| 96 | const RandomNumberEngineNameValidator *inst = | 
|---|
| 97 | dynamic_cast<const RandomNumberEngineNameValidator *>(&_instance); | 
|---|
| 98 | if (inst) | 
|---|
| 99 | return true; | 
|---|
| 100 | else | 
|---|
| 101 | return false; | 
|---|
| 102 | } | 
|---|
| 103 |  | 
|---|
| 104 | Validator< std::string >* RandomNumberEngineNameValidator::clone() const | 
|---|
| 105 | { | 
|---|
| 106 | Validator< std::string > *inst = | 
|---|
| 107 | new RandomNumberEngineNameValidator(); | 
|---|
| 108 | return inst; | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 |  | 
|---|
| 112 |  | 
|---|
| 113 |  | 
|---|