source: src/Parameters/Validators/Ops_Validator_impl.hpp@ 0cd8cf

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 0cd8cf was e59e8e, checked in by Frederik Heber <heber@…>, 12 years ago

ParserTypeValidator + And_Validator: values readable by QtQueryList

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Ops_Validator_impl.hpp
3 *
4 * Created on: May 9, 2012
5 * Author: ankele
6 */
7
8#ifndef OPS_VALIDATOR_IMPL_HPP_
9#define OPS_VALIDATOR_IMPL_HPP_
10
11
12
13// include config.h
14#ifdef HAVE_CONFIG_H
15#include <config.h>
16#endif
17
18#include "Validator.hpp"
19
20/** Logical AND composition of two Validators.
21 *
22 */
23template <class T>
24class And_Validator : public Validator<T>
25{
26public:
27 And_Validator(const Validator<T> &_a, const Validator<T> &_b) :
28 a(_a.clone()), b(_b.clone())
29 {}
30 virtual ~And_Validator()
31 {
32 delete(a);
33 delete(b);
34 }
35
36 bool isValid(const T & _value) const {
37 return (*a)(_value) && (*b)(_value);
38 }
39
40 Validator<T>* clone() const
41 { return new And_Validator(*a, *b); }
42
43 // comparator
44 bool operator==(const Validator<T> &_instance) const
45 {
46 const And_Validator<T> *inst = dynamic_cast<const And_Validator<T> *>(&_instance);
47 if (inst)
48 return (*a == *inst->a) && (*b == *inst->b);
49 return false;
50 }
51
52 Validator<T> *getA(){ return a; }
53 Validator<T> *getB(){ return b; }
54
55private:
56 Validator<T> *a;
57 Validator<T> *b;
58};
59
60/** Logical OR composition of two Validators.
61 *
62 */
63template <class T>
64class Or_Validator : public Validator<T>
65{
66public:
67 Or_Validator(const Validator<T> &_a, const Validator<T> &_b) :
68 a(_a.clone()), b(_b.clone())
69 {}
70 virtual ~Or_Validator()
71 {
72 delete(a);
73 delete(b);
74 }
75
76 bool isValid(const T & _value) const {
77 return (*a)(_value) || (*b)(_value);
78 }
79
80 Validator<T>* clone() const
81 { return new Or_Validator(*a, *b); }
82
83 // comparator
84 bool operator==(const Validator<T> &_instance) const
85 {
86 const Or_Validator<T> *inst = dynamic_cast<const Or_Validator<T> *>(&_instance);
87 if (inst)
88 return (*a == *inst->a) && (*b == *inst->b);
89 return false;
90 }
91
92private:
93 Validator<T> *a;
94 Validator<T> *b;
95};
96
97/** Logical NOT composition of a Validator.
98 *
99 */
100template <class T>
101class Not_Validator : public Validator<T>
102{
103public:
104 Not_Validator(const Validator<T> &_a) :
105 a(_a.clone())
106 {}
107 virtual ~Not_Validator()
108 {
109 delete(a);
110 }
111
112 bool isValid(const T & _value) const {
113 return !(*a)(_value);
114 }
115
116 Validator<T>* clone() const
117 { return new Not_Validator(*a); }
118
119 // comparator
120 bool operator==(const Validator<T> &_instance) const
121 {
122 const Not_Validator<T> *inst = dynamic_cast<const Not_Validator<T> *>(&_instance);
123 if (inst)
124 return (*a == *inst->a);
125 return false;
126 }
127
128private:
129 Validator<T> *a;
130};
131
132
133
134template <class T>
135And_Validator<T> operator&&(const Validator<T> &a, const Validator<T> &b)
136{
137 return And_Validator<T>(a, b);
138}
139
140template <class T>
141Or_Validator<T> operator||(const Validator<T> &a, const Validator<T> &b)
142{
143 return Or_Validator<T>(a, b);
144}
145
146template <class T>
147Not_Validator<T> operator!(const Validator<T> &a)
148{
149 return Not_Validator<T>(a);
150}
151
152
153#endif /* OPS_VALIDATOR_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.