Changeset dbb474 for src/Descriptors
- Timestamp:
- Mar 3, 2010, 1:57:41 PM (15 years ago)
- Branches:
- 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
- Children:
- 1c51c8
- Parents:
- a1510d
- Location:
- src/Descriptors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Descriptors/AtomDescriptor.hpp
ra1510d rdbb474 21 21 class AtomDescripter_impl; 22 22 23 /** 24 * An AtomDescriptor describes a Set of Atoms from the World. Can be used for any method that needs to work on 25 * a specific set of Atoms. 26 * 27 * This Class is implemented using the PIMPL-Idion, i.e. this class only contains an abstract structure 28 * that forwards any request to a wrapped pointer-to-implementation. This way operators and calculations 29 * on Descriptors are possible. 30 * 31 * Concrete Implementation Objects can be shared between multiple Wrappers, so make sure that 32 * any Implementation remainst constant during lifetime. 33 */ 23 34 class AtomDescriptor { 24 35 // close coupling to the world to allow access … … 32 43 33 44 public: 34 typedef boost::shared_ptr<AtomDescriptor_impl> impl_ptr; 45 typedef boost::shared_ptr<AtomDescriptor_impl> impl_ptr; //!< Allow easy changes of the pointer-to-implementation type 35 46 36 47 AtomDescriptor(impl_ptr); 48 49 /** 50 * Copy constructor. 51 * Takes the Implementation from the copied object and sets it's own pointer to link there. 52 * This way the actuall implementation object is shared between copy and original 53 */ 37 54 AtomDescriptor(const AtomDescriptor&); 38 55 ~AtomDescriptor(); 39 56 57 /** 58 * Assignment Operator. 59 * 60 * Implemented by setting the pointer to the new Implementation. 61 */ 40 62 AtomDescriptor &operator=(AtomDescriptor &); 41 63 42 64 protected: 65 /** 66 * forward Method to implementation 67 */ 43 68 atom* find(); 69 70 /** 71 * forward Method to implementation 72 */ 44 73 std::vector<atom*> findAll(); 74 75 /** 76 * Return the implementation this Wrapper currently points to. 77 * Used for copying, assignment and in Iterators over subsets of the World. 78 */ 45 79 impl_ptr get_impl() const; 46 80 … … 49 83 }; 50 84 51 // Functions to construct actual descriptors 85 /** 86 * produce an Atomdescriptor that at the point of construction contains an implementation that matches all Atoms 87 */ 52 88 AtomDescriptor AllAtoms(); 89 90 /** 91 * produce an Atomdescriptor that at the point of construction contains an implementation that matches no Atoms 92 */ 53 93 AtomDescriptor NoAtoms(); 54 94 55 // no true short circuit, but the test of the second descriptor wont be done 95 /** 96 * Set Intersection for two Atomdescriptors. The resulting Atomdescriptor will only match an Atom if both 97 * given Atomdescriptors also match. Uses short circuit inside, so the second predicate wont be called 98 * when the first one failed. 99 */ 56 100 AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs); 101 102 /** 103 * Set Union for two AtomDescriptors. The resulting AtomDescriptor will match an Atom if at least one of 104 * the two given AtomDescriptors does match. Used short circuit inside, so the second predicate wont 105 * be called when the first one failed. 106 */ 57 107 AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs); 108 109 /** 110 * Set inversion for an AtomDescriptor. Matches an Atom if the given AtomDescriptor did not match. 111 */ 58 112 AtomDescriptor operator!(const AtomDescriptor &arg); 59 113 -
src/Descriptors/AtomDescriptor_impl.hpp
ra1510d rdbb474 5 5 6 6 /************************ Declarations of implementation Objects ************************/ 7 8 /** 9 * This class implements a general Base class for AtomDescriptors 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 atoms should be picked for a given descriptor. 13 */ 7 14 8 15 class AtomDescriptor_impl … … 14 21 virtual ~AtomDescriptor_impl(); 15 22 23 /** 24 * Implement this abstract Method to make a concrete AtomDescriptor pick certain Atoms 25 */ 16 26 virtual bool predicate(std::pair<atomId_t,atom*>)=0; 17 27 18 28 protected: 29 30 /** 31 * This method is called when the Descriptor is used to find the first matching 32 * Atom. Walks through all Atoms and stops on the first match. Can be implemented 33 * when the searched Atom can be found in a more efficient way. Calculated 34 * Atomdescriptors will always use this method, so no improvement there. 35 */ 19 36 virtual atom* find(); 37 38 /** 39 * This method is called when the Descriptor is used to find all matching Atoms. 40 * Walks through all Atoms and tests the predicate on each one. A vector of all 41 * matching Atoms is returned. 42 */ 20 43 virtual std::vector<atom*> findAll(); 44 45 /** 46 * This method is used internally to query the Set of Atoms 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 */ 21 51 World::AtomSet& getAtoms(); 22 52 }; … … 24 54 /************************** Universe and Emptyset *****************/ 25 55 56 /** 57 * A simple AtomDescriptor that will always match all Atoms present in the World. 58 */ 26 59 class AtomAllDescriptor_impl : public AtomDescriptor_impl { 27 60 public: 28 61 AtomAllDescriptor_impl(); 29 62 virtual ~AtomAllDescriptor_impl(); 63 64 /** 65 * Always returns true for any Atom 66 */ 30 67 virtual bool predicate(std::pair<atomId_t,atom*>); 31 68 }; 32 69 70 71 /** 72 * An AtomDescriptor that never matches any Atom in the World. 73 */ 33 74 class AtomNoneDescriptor_impl : public AtomDescriptor_impl { 34 75 public: 35 76 AtomNoneDescriptor_impl(); 36 77 virtual ~AtomNoneDescriptor_impl(); 78 79 /** 80 * Always returns false for any Atom 81 */ 37 82 virtual bool predicate(std::pair<atomId_t,atom*>); 38 83 }; … … 40 85 /************************** Operator stuff ************************/ 41 86 87 /** 88 * Intersection of two AtomDescriptors 89 */ 42 90 class AtomAndDescriptor_impl : public AtomDescriptor_impl 43 91 { … … 45 93 AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs); 46 94 ~AtomAndDescriptor_impl(); 95 96 /** 97 * This predicate uses the predicate from the first && the predicate from the 98 * second Descriptor to decide if an Atom should be selected. 99 */ 47 100 virtual bool predicate(std::pair<atomId_t,atom*>); 48 101 … … 52 105 }; 53 106 107 /** 108 * Union of two AtomDescriptors 109 */ 54 110 class AtomOrDescriptor_impl : public AtomDescriptor_impl 55 111 { … … 57 113 AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs); 58 114 virtual ~AtomOrDescriptor_impl(); 115 116 /** 117 * This predicate uses the predicate form the first || the predicate from the 118 * second Descriptor to decide if an Atom should be selected. 119 */ 59 120 virtual bool predicate(std::pair<atomId_t,atom*>); 60 121 … … 64 125 }; 65 126 127 /** 128 * Set Inversion of a Descriptor 129 */ 66 130 class AtomNotDescriptor_impl : public AtomDescriptor_impl 67 131 { … … 70 134 virtual ~AtomNotDescriptor_impl(); 71 135 136 /** 137 * Opposite of the given descriptor predicate. 138 */ 72 139 virtual bool predicate(std::pair<atomId_t,atom*>); 73 140
Note:
See TracChangeset
for help on using the changeset viewer.