source: src/Descriptors/AtomDescriptor_impl.hpp@ 4464ef

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 4464ef was 795c0f, checked in by Frederik Heber <heber@…>, 9 years ago

World::getAtoms() now has const versions as well.

  • this in turn required to adapt all AtomDescriptors and some fixes, e.g. predicate is now const member and works on const atom ptr.
  • Property mode set to 100644
File size: 5.1 KB
RevLine 
[f16a4b]1#ifndef ATOMDESCRIPTOR_IMPL_HPP
2#define ATOMDESCRIPTOR_IMPL_HPP
3
[56f73b]4// include config.h
5#ifdef HAVE_CONFIG_H
6#include <config.h>
7#endif
8
9
[7042f45]10#include "Descriptors/AtomDescriptor.hpp"
11
[7a1ce5]12/************************ Declarations of implementation Objects ************************/
13
[dbb474]14/**
15 * This class implements a general Base class for AtomDescriptors using the PIMPL-Idiom
16 *
17 * The predicate for this class is empty and should be implemented by derived classes.
18 * By the predicate it is described which atoms should be picked for a given descriptor.
19 */
20
[7a1ce5]21class AtomDescriptor_impl
22{
23 friend class AtomDescriptor;
24public:
25
26 AtomDescriptor_impl();
27 virtual ~AtomDescriptor_impl();
28
[dbb474]29 /**
30 * Implement this abstract Method to make a concrete AtomDescriptor pick certain Atoms
31 */
[795c0f]32 virtual bool predicate(std::pair<atomId_t,const atom*>) const=0;
[7a1ce5]33
34protected:
[dbb474]35
36 /**
37 * This method is called when the Descriptor is used to find the first matching
38 * Atom. Walks through all Atoms and stops on the first match. Can be implemented
39 * when the searched Atom can be found in a more efficient way. Calculated
40 * Atomdescriptors will always use this method, so no improvement there.
41 */
[7a1ce5]42 virtual atom* find();
[dbb474]43
[795c0f]44 /**
45 * This method is called when the Descriptor is used to find the first matching
46 * Atom. Walks through all Atoms and stops on the first match. Can be implemented
47 * when the searched Atom can be found in a more efficient way. Calculated
48 * Atomdescriptors will always use this method, so no improvement there.
49 */
50 virtual const atom* find() const;
51
[dbb474]52 /**
53 * This method is called when the Descriptor is used to find all matching Atoms.
54 * Walks through all Atoms and tests the predicate on each one. A vector of all
55 * matching Atoms is returned.
56 */
[7a1ce5]57 virtual std::vector<atom*> findAll();
[dbb474]58
[795c0f]59 /**
60 * This method is called when the Descriptor is used to find all matching Atoms.
61 * Walks through all Atoms and tests the predicate on each one. A vector of all
62 * matching Atoms is returned.
63 */
64 virtual std::vector<const atom*> findAll() const;
65
[dbb474]66 /**
67 * This method is used internally to query the Set of Atoms from the world.
68 * By using this method derived classes can also access the Internal World Datastructre.
69 * Implemented in full in the Base Descriptor Implementation, so only this one method
70 * needs to be friend with the World class.
71 */
[7042f45]72 World::AtomSet& getAtoms();
[8cce2b]73
[795c0f]74 /**
75 * This method is used internally to query the Set of Atoms from the world.
76 * By using this method derived classes can also access the Internal World Datastructre.
77 * Implemented in full in the Base Descriptor Implementation, so only this one method
78 * needs to be friend with the World class.
79 */
80 const World::AtomSet& getAtoms() const;
81
[8cce2b]82 void checkAndAdd(std::vector<atom*>*,std::pair<atomId_t,atom*>);
[795c0f]83
84 void checkAndAdd(std::vector<const atom*>*,std::pair<atomId_t,const atom*>) const;
[7a1ce5]85};
86
87/************************** Universe and Emptyset *****************/
88
[dbb474]89/**
90 * A simple AtomDescriptor that will always match all Atoms present in the World.
91 */
[7a1ce5]92class AtomAllDescriptor_impl : public AtomDescriptor_impl {
93public:
94 AtomAllDescriptor_impl();
95 virtual ~AtomAllDescriptor_impl();
[dbb474]96
97 /**
98 * Always returns true for any Atom
99 */
[795c0f]100 virtual bool predicate(std::pair<atomId_t, const atom*>) const;
[7a1ce5]101};
102
[dbb474]103
104/**
105 * An AtomDescriptor that never matches any Atom in the World.
106 */
[7a1ce5]107class AtomNoneDescriptor_impl : public AtomDescriptor_impl {
108public:
109 AtomNoneDescriptor_impl();
110 virtual ~AtomNoneDescriptor_impl();
[dbb474]111
112 /**
113 * Always returns false for any Atom
114 */
[795c0f]115 virtual bool predicate(std::pair<atomId_t,const atom*>)const;
[7a1ce5]116};
117
118/************************** Operator stuff ************************/
119
[dbb474]120/**
121 * Intersection of two AtomDescriptors
122 */
[7a1ce5]123class AtomAndDescriptor_impl : public AtomDescriptor_impl
124{
125public:
126 AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
127 ~AtomAndDescriptor_impl();
[dbb474]128
129 /**
130 * This predicate uses the predicate from the first && the predicate from the
131 * second Descriptor to decide if an Atom should be selected.
132 */
[795c0f]133 virtual bool predicate(std::pair<atomId_t,const atom*>) const;
[7a1ce5]134
135private:
136 AtomDescriptor::impl_ptr lhs;
137 AtomDescriptor::impl_ptr rhs;
138};
139
[dbb474]140/**
141 * Union of two AtomDescriptors
142 */
[7a1ce5]143class AtomOrDescriptor_impl : public AtomDescriptor_impl
144{
145public:
146 AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
147 virtual ~AtomOrDescriptor_impl();
[dbb474]148
149 /**
150 * This predicate uses the predicate form the first || the predicate from the
151 * second Descriptor to decide if an Atom should be selected.
152 */
[795c0f]153 virtual bool predicate(std::pair<atomId_t,const atom*>) const;
[7a1ce5]154
155private:
156 AtomDescriptor::impl_ptr lhs;
157 AtomDescriptor::impl_ptr rhs;
158};
159
[dbb474]160/**
161 * Set Inversion of a Descriptor
162 */
[7a1ce5]163class AtomNotDescriptor_impl : public AtomDescriptor_impl
164{
165public:
166 AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg);
167 virtual ~AtomNotDescriptor_impl();
168
[dbb474]169 /**
170 * Opposite of the given descriptor predicate.
171 */
[795c0f]172 virtual bool predicate(std::pair<atomId_t,const atom*>) const;
[7a1ce5]173
174private:
175 AtomDescriptor::impl_ptr arg;
176};
[f16a4b]177
178#endif //ATOMDESCRIPTOR_IMPL_HPP
Note: See TracBrowser for help on using the repository browser.