source: src/Descriptors/MoleculeDescriptor.cpp@ 906822

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 906822 was 112b09, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added #include "Helpers/MemDebug.hpp" to all .cpp files

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * MoleculeDescriptor.cpp
3 *
4 * Created on: Feb 5, 2010
5 * Author: crueger
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Descriptors/MoleculeDescriptor.hpp"
11#include "Descriptors/MoleculeDescriptor_impl.hpp"
12
13#include "World.hpp"
14
15#include "molecule.hpp"
16
17#include <boost/bind.hpp>
18#include <cassert>
19#include <iostream>
20
21using namespace std;
22
23typedef World::MoleculeSet::iterator molecules_iter_t;
24
25/************************ Forwarding object **************************************/
26
27
28MoleculeDescriptor::MoleculeDescriptor(impl_ptr _impl) :
29 impl(_impl)
30{}
31
32MoleculeDescriptor::MoleculeDescriptor(const MoleculeDescriptor& src) :
33 impl(src.get_impl())
34{}
35
36MoleculeDescriptor::~MoleculeDescriptor()
37{}
38
39MoleculeDescriptor& MoleculeDescriptor::operator=(MoleculeDescriptor &src){
40 if(&src!=this) {
41 impl=src.get_impl();
42 }
43 return *this;
44}
45
46molecule* MoleculeDescriptor::find(){
47 return impl->find();
48}
49
50std::vector<molecule*> MoleculeDescriptor::findAll(){
51 return impl->findAll();
52}
53
54MoleculeDescriptor::impl_ptr MoleculeDescriptor::get_impl() const{
55 return impl;
56}
57
58
59
60
61/**************************** implementation ********************/
62
63MoleculeDescriptor_impl::MoleculeDescriptor_impl()
64{
65}
66
67MoleculeDescriptor_impl::~MoleculeDescriptor_impl()
68{
69}
70
71World::MoleculeSet& MoleculeDescriptor_impl::getMolecules(){
72 return World::getInstance().molecules;
73}
74
75molecule* MoleculeDescriptor_impl::find() {
76 World::MoleculeSet molecules = getMolecules();
77 molecules_iter_t res = find_if(molecules.begin(),molecules.end(),boost::bind(&MoleculeDescriptor_impl::predicate,this,_1));
78 return (res!=molecules.end())?((*res).second):0;
79}
80
81vector<molecule*> MoleculeDescriptor_impl::findAll() {
82 vector<molecule*> res;
83 World::MoleculeSet molecules = getMolecules();
84 molecules_iter_t iter;
85 for(iter=molecules.begin();iter!=molecules.end();++iter) {
86 if(predicate(*iter)){
87 res.push_back((*iter).second);
88 }
89 }
90 return res;
91}
92
93/************************** Universe and Emptyset *****************/
94
95MoleculeAllDescriptor_impl::MoleculeAllDescriptor_impl()
96{}
97
98MoleculeAllDescriptor_impl::~MoleculeAllDescriptor_impl()
99{}
100
101bool MoleculeAllDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*>){
102 return true;
103}
104
105MoleculeDescriptor AllMolecules(){
106 return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeAllDescriptor_impl));
107}
108
109MoleculeNoneDescriptor_impl::MoleculeNoneDescriptor_impl()
110{}
111
112MoleculeNoneDescriptor_impl::~MoleculeNoneDescriptor_impl()
113{}
114
115bool MoleculeNoneDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*>){
116 return false;
117}
118
119MoleculeDescriptor NoMolecules(){
120 return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeNoneDescriptor_impl));
121}
122
123/************************** Operator stuff ************************/
124
125// AND
126MoleculeAndDescriptor_impl::MoleculeAndDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs, MoleculeDescriptor::impl_ptr _rhs) :
127 lhs(_lhs), rhs(_rhs)
128{}
129
130MoleculeAndDescriptor_impl::~MoleculeAndDescriptor_impl()
131{}
132
133bool MoleculeAndDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
134 return lhs->predicate(molecule) && rhs->predicate(molecule);
135}
136MoleculeDescriptor operator&&(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs){
137 MoleculeDescriptor::impl_ptr newImpl = MoleculeDescriptor::impl_ptr(new MoleculeAndDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
138 return MoleculeDescriptor(newImpl);
139}
140
141// OR
142MoleculeOrDescriptor_impl::MoleculeOrDescriptor_impl(MoleculeDescriptor::impl_ptr _lhs ,MoleculeDescriptor::impl_ptr _rhs) :
143 lhs(_lhs), rhs(_rhs)
144{}
145
146MoleculeOrDescriptor_impl::~MoleculeOrDescriptor_impl(){
147}
148
149bool MoleculeOrDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
150 return lhs->predicate(molecule) || rhs->predicate(molecule);
151}
152
153MoleculeDescriptor operator||(const MoleculeDescriptor &lhs, const MoleculeDescriptor &rhs){
154 MoleculeDescriptor::impl_ptr newImpl = MoleculeDescriptor::impl_ptr(new MoleculeOrDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
155 return MoleculeDescriptor(newImpl);
156}
157
158// NOT
159
160MoleculeNotDescriptor_impl::MoleculeNotDescriptor_impl(MoleculeDescriptor::impl_ptr _arg) :
161 arg(_arg)
162{}
163
164
165MoleculeNotDescriptor_impl::~MoleculeNotDescriptor_impl()
166{
167}
168
169bool MoleculeNotDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
170 return !(arg->predicate(molecule));
171}
172
173MoleculeDescriptor operator!(const MoleculeDescriptor &arg){
174 MoleculeDescriptor::impl_ptr newImpl = MoleculeDescriptor::impl_ptr(new MoleculeNotDescriptor_impl(arg.get_impl()));
175 return MoleculeDescriptor(newImpl);
176}
Note: See TracBrowser for help on using the repository browser.