source: src/Descriptors/MoleculeDescriptor.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 97445f, checked in by Frederik Heber <heber@…>, 9 years ago

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

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * MoleculeDescriptor.hpp
3 *
4 * Created on: Feb 5, 2010
5 * Author: crueger
6 */
7
8#ifndef MOLECULEDESCRIPTOR_HPP_
9#define MOLECULEDESCRIPTOR_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
17
18#include <vector>
19#include <map>
20#include <boost/shared_ptr.hpp>
21#include "World.hpp"
22
23class World;
24class molecule;
25
26// internal implementation, allows assignment, copying etc
27class MoleculeDescriptor_impl;
28
29/**
30 * An MoleculeDescriptor describes a Set of Molecules from the World. Can be used for any method that needs to work on
31 * a specific set of Molecules.
32 *
33 * This Class is implemented using the PIMPL-Idion, i.e. this class only contains an abstract structure
34 * that forwards any request to a wrapped pointer-to-implementation. This way operators and calculations
35 * on Descriptors are possible.
36 *
37 * Concrete Implementation Objects can be shared between multiple Wrappers, so make sure that
38 * any Implementation remainst constant during lifetime.
39 */
40class MoleculeDescriptor {
41 // close coupling to the world to allow access
42 friend molecule* World::getMolecule(MoleculeDescriptor descriptor);
43 friend const molecule* World::getMolecule(MoleculeDescriptor descriptor) const;
44 friend std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor);
45 friend std::vector<const molecule*> World::getAllMolecules(MoleculeDescriptor descriptor) const;
46 template <class,class,class> friend class SelectiveIterator;
47 template <class,class,class> friend class SelectiveConstIterator;
48
49 friend MoleculeDescriptor operator&&(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
50 friend MoleculeDescriptor operator||(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
51 friend MoleculeDescriptor operator!(const MoleculeDescriptor &arg);
52
53public:
54 typedef MoleculeDescriptor_impl impl_t;
55 typedef boost::shared_ptr<impl_t> impl_ptr; //!< Allow easy changes of the pointer-to-implementation type
56
57 MoleculeDescriptor(impl_ptr);
58
59 /**
60 * Copy constructor.
61 * Takes the Implementation from the copied object and sets it's own pointer to link there.
62 * This way the actuall implementation object is shared between copy and original
63 */
64 MoleculeDescriptor(const MoleculeDescriptor&);
65 ~MoleculeDescriptor();
66
67 /**
68 * Assignment Operator.
69 *
70 * Implemented by setting the pointer to the new Implementation.
71 */
72 MoleculeDescriptor &operator=(MoleculeDescriptor &);
73
74protected:
75 /**
76 * forward Method to implementation
77 */
78 molecule* find();
79
80 /**
81 * forward Method to implementation
82 */
83 const molecule* find() const;
84
85 /**
86 * forward Method to implementation
87 */
88 std::vector<molecule*> findAll();
89
90 /**
91 * forward Method to implementation
92 */
93 std::vector<const molecule*> findAll() const;
94
95 /**
96 * Return the implementation this Wrapper currently points to.
97 * Used for copying, assignment and in Iterators over subsets of the World.
98 */
99 impl_ptr get_impl() const;
100
101private:
102 impl_ptr impl;
103};
104
105/**
106 * produce an Moleculedescriptor that at the point of construction contains an implementation that matches all Molecules
107 */
108MoleculeDescriptor AllMolecules();
109
110/**
111 * produce an Moleculedescriptor that at the point of construction contains an implementation that matches no Molecules
112 */
113MoleculeDescriptor NoMolecules();
114
115/**
116 * Set Intersection for two Moleculedescriptors. The resulting Moleculedescriptor will only match an Molecule if both
117 * given Moleculedescriptors also match. Uses short circuit inside, so the second predicate wont be called
118 * when the first one failed.
119 */
120MoleculeDescriptor operator&&(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
121
122/**
123 * Set Union for two MoleculeDescriptors. The resulting MoleculeDescriptor will match an Molecule if at least one of
124 * the two given MoleculeDescriptors does match. Used short circuit inside, so the second predicate wont
125 * be called when the first one failed.
126 */
127MoleculeDescriptor operator||(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs);
128
129/**
130 * Set inversion for an MoleculeDescriptor. Matches an Molecule if the given MoleculeDescriptor did not match.
131 */
132MoleculeDescriptor operator!(const MoleculeDescriptor &arg);
133
134#endif /* MOLECULEDESCRIPTOR_HPP_ */
Note: See TracBrowser for help on using the repository browser.