source: src/Descriptors/MoleculeDescriptor_impl.hpp@ 5f8660a

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 5f8660a was 8cce2b, checked in by Tillmann Crueger <crueger@…>, 14 years ago

Made the MoleculeDescriptor and AtomDescriptor use faster STL-Algorithms for finding

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[1c51c8]1#ifndef MOLECULEDESCRIPTOR_IMPL_HPP
2#define MOLECULEDESCRIPTOR_IMPL_HPP
3
4#include "Descriptors/MoleculeDescriptor.hpp"
5
6/************************ Declarations of implementation Objects ************************/
7
8/**
9 * This class implements a general Base class for MoleculeDescriptors using the PIMPL-Idiom
10 *
11 * The predicate for this class is empty and should be implemented by derived classes.
12 * By the predicate it is described which molecules should be picked for a given descriptor.
13 */
14
15class MoleculeDescriptor_impl
16{
17 friend class MoleculeDescriptor;
18public:
19
20 MoleculeDescriptor_impl();
21 virtual ~MoleculeDescriptor_impl();
22
23 /**
24 * Implement this abstract Method to make a concrete MoleculeDescriptor pick certain Molecules
25 */
26 virtual bool predicate(std::pair<moleculeId_t,molecule*>)=0;
27
28protected:
29
30 /**
31 * This method is called when the Descriptor is used to find the first matching
32 * Molecule. Walks through all Molecules and stops on the first match. Can be implemented
33 * when the searched Molecule can be found in a more efficient way. Calculated
34 * Moleculedescriptors will always use this method, so no improvement there.
35 */
36 virtual molecule* find();
37
38 /**
39 * This method is called when the Descriptor is used to find all matching Molecules.
40 * Walks through all Molecules and tests the predicate on each one. A vector of all
41 * matching Molecules is returned.
42 */
43 virtual std::vector<molecule*> findAll();
44
45 /**
46 * This method is used internally to query the Set of Molecules from the world.
47 * By using this method derived classes can also access the Internal World Datastructre.
48 * Implemented in full in the Base Descriptor Implementation, so only this one method
49 * needs to be friend with the World class.
50 */
51 World::MoleculeSet& getMolecules();
[8cce2b]52
53 void checkAndAdd(std::vector<molecule*>*,std::pair<moleculeId_t,molecule*>);
[1c51c8]54};
55
56/************************** Universe and Emptyset *****************/
57
58/**
59 * A simple MoleculeDescriptor that will always match all Molecules present in the World.
60 */
61class MoleculeAllDescriptor_impl : public MoleculeDescriptor_impl {
62public:
63 MoleculeAllDescriptor_impl();
64 virtual ~MoleculeAllDescriptor_impl();
65
66 /**
67 * Always returns true for any Molecule
68 */
69 virtual bool predicate(std::pair<moleculeId_t,molecule*>);
70};
71
72
73/**
74 * An MoleculeDescriptor that never matches any Molecule in the World.
75 */
76class MoleculeNoneDescriptor_impl : public MoleculeDescriptor_impl {
77public:
78 MoleculeNoneDescriptor_impl();
79 virtual ~MoleculeNoneDescriptor_impl();
80
81 /**
82 * Always returns false for any Molecule
83 */
84 virtual bool predicate(std::pair<moleculeId_t,molecule*>);
85};
86
87/************************** Operator stuff ************************/
88
89/**
90 * Intersection of two MoleculeDescriptors
91 */
92class MoleculeAndDescriptor_impl : public MoleculeDescriptor_impl
93{
94public:
95 MoleculeAndDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs, MoleculeDescriptor::impl_ptr _rhs);
96 ~MoleculeAndDescriptor_impl();
97
98 /**
99 * This predicate uses the predicate from the first && the predicate from the
100 * second Descriptor to decide if an Molecule should be selected.
101 */
102 virtual bool predicate(std::pair<moleculeId_t,molecule*>);
103
104private:
105 MoleculeDescriptor::impl_ptr lhs;
106 MoleculeDescriptor::impl_ptr rhs;
107};
108
109/**
110 * Union of two MoleculeDescriptors
111 */
112class MoleculeOrDescriptor_impl : public MoleculeDescriptor_impl
113{
114public:
115 MoleculeOrDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs, MoleculeDescriptor::impl_ptr _rhs);
116 virtual ~MoleculeOrDescriptor_impl();
117
118 /**
119 * This predicate uses the predicate form the first || the predicate from the
120 * second Descriptor to decide if an Molecule should be selected.
121 */
122 virtual bool predicate(std::pair<moleculeId_t,molecule*>);
123
124private:
125 MoleculeDescriptor::impl_ptr lhs;
126 MoleculeDescriptor::impl_ptr rhs;
127};
128
129/**
130 * Set Inversion of a Descriptor
131 */
132class MoleculeNotDescriptor_impl : public MoleculeDescriptor_impl
133{
134public:
135 MoleculeNotDescriptor_impl(MoleculeDescriptor::impl_ptr _arg);
136 virtual ~MoleculeNotDescriptor_impl();
137
138 /**
139 * Opposite of the given descriptor predicate.
140 */
141 virtual bool predicate(std::pair<moleculeId_t,molecule*>);
142
143private:
144 MoleculeDescriptor::impl_ptr arg;
145};
146
147#endif //MOLECULEDESCRIPTOR_IMPL_HPP
Note: See TracBrowser for help on using the repository browser.