source: src/Descriptors/AtomDescriptor.cpp@ b99bf3

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

Moved the observedContainer templates to the Pattern directory

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