source: src/Parameters/Validators/Ops_Validator_impl.hpp@ dae158

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 dae158 was dae158, checked in by Frederik Heber <heber@…>, 10 years ago

FileQtQuery retrieves valid suffixes from validators.

  • added getFlatListFromHierarchyOfValidators() that steps through the hierarchy of validators and generates a flat vector with all matching types.
  • Or_Validatorm Not_Validator::getA(), ::getB() added. (present for And_... already).
  • FileSuffixValidator::getSuffix(), ParserFileValidator::getSuffixes() added.
  • Property mode set to 100644
File size: 3.1 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 const Validator<T> *getA() const { return a; }
55 const Validator<T> *getB() const { return b; }
56
57private:
58 Validator<T> *a;
59 Validator<T> *b;
60};
61
62/** Logical OR composition of two Validators.
63 *
64 */
65template <class T>
66class Or_Validator : public Validator<T>
67{
68public:
69 Or_Validator(const Validator<T> &_a, const Validator<T> &_b) :
70 a(_a.clone()), b(_b.clone())
71 {}
72 virtual ~Or_Validator()
73 {
74 delete(a);
75 delete(b);
76 }
77
78 bool isValid(const T & _value) const {
79 return (*a)(_value) || (*b)(_value);
80 }
81
82 Validator<T>* clone() const
83 { return new Or_Validator(*a, *b); }
84
85 // comparator
86 bool operator==(const Validator<T> &_instance) const
87 {
88 const Or_Validator<T> *inst = dynamic_cast<const Or_Validator<T> *>(&_instance);
89 if (inst)
90 return (*a == *inst->a) && (*b == *inst->b);
91 return false;
92 }
93
94 Validator<T> *getA(){ return a; }
95 Validator<T> *getB(){ return b; }
96 const Validator<T> *getA() const { return a; }
97 const Validator<T> *getB() const { return b; }
98
99private:
100 Validator<T> *a;
101 Validator<T> *b;
102};
103
104/** Logical NOT composition of a Validator.
105 *
106 */
107template <class T>
108class Not_Validator : public Validator<T>
109{
110public:
111 Not_Validator(const Validator<T> &_a) :
112 a(_a.clone())
113 {}
114 virtual ~Not_Validator()
115 {
116 delete(a);
117 }
118
119 bool isValid(const T & _value) const {
120 return !(*a)(_value);
121 }
122
123 Validator<T>* clone() const
124 { return new Not_Validator(*a); }
125
126 // comparator
127 bool operator==(const Validator<T> &_instance) const
128 {
129 const Not_Validator<T> *inst = dynamic_cast<const Not_Validator<T> *>(&_instance);
130 if (inst)
131 return (*a == *inst->a);
132 return false;
133 }
134
135 Validator<T> *getA(){ return a; }
136 const Validator<T> *getA() const { return a; }
137
138private:
139 Validator<T> *a;
140};
141
142
143
144template <class T>
145And_Validator<T> operator&&(const Validator<T> &a, const Validator<T> &b)
146{
147 return And_Validator<T>(a, b);
148}
149
150template <class T>
151Or_Validator<T> operator||(const Validator<T> &a, const Validator<T> &b)
152{
153 return Or_Validator<T>(a, b);
154}
155
156template <class T>
157Not_Validator<T> operator!(const Validator<T> &a)
158{
159 return Not_Validator<T>(a);
160}
161
162
163#endif /* OPS_VALIDATOR_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.