Changeset 7c4e29


Ignore:
Timestamp:
Feb 19, 2010, 11:49:42 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
afb47f
Parents:
b2cfdb
git-author:
Tillmann Crueger <crueger@…> (02/19/10 11:31:39)
git-committer:
Tillmann Crueger <crueger@…> (02/19/10 11:49:42)
Message:

Added a class that allows constructing Processes that have a result

Location:
src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Process.cpp

    rb2cfdb r7c4e29  
    3838
    3939int Process::getCurrStep(){
     40  OBSERVE;
    4041  return currStep;
     42}
     43
     44void Process::setCurrStep(int _currStep){
     45  currStep = _currStep;
    4146}
    4247
     
    4752    return 0;
    4853}
     54
    4955int Process::getMaxSteps(){
    5056  return maxSteps;
    5157}
    5258
     59void Process::setMaxSteps(int _maxSteps){
     60  maxSteps = _maxSteps;
     61}
    5362
    5463void Process::start(){
     
    6978  starts = false;
    7079}
     80
    7181void Process::step(){
    7282  OBSERVE;
    7383  currStep++;
    7484}
     85
    7586void Process::stop(){
    7687  stops = true;
  • src/Actions/Process.hpp

    rb2cfdb r7c4e29  
    2929  bool  doesStop();
    3030  int   getCurrStep();
     31  void  setCurrStep(int _currStep);
    3132  float getDoneRatio();
    3233  int   getMaxSteps();
     34  void  setMaxSteps(int _maxSteps);
    3335
    3436protected:
  • src/Makefile.am

    rb2cfdb r7c4e29  
    88ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp
    99
    10 ACTIONSSOURCE = Actions/Action.cpp Actions/Process.cpp Actions/MethodAction.cpp Actions/ActionSequence.cpp Actions/MakroAction.cpp Actions/ErrorAction.cpp Actions/small_actions.cpp Actions/ActionRegistry.cpp
    11 ACTIONSHEADER = Actions/Action.hpp Actions/Process.hpp Actions/MethodAction.hpp Actions/ActionSequence.hpp Actions/MakroAction.hpp Actions/ErrorAction.hpp Actions/small_actions.hpp Actions/ActionRegistry.hpp
     10ACTIONSSOURCE = Actions/Action.cpp Actions/Process.cpp Actions/MethodAction.cpp Actions/ActionSequence.cpp Actions/MakroAction.cpp Actions/ErrorAction.cpp Actions/small_actions.cpp Actions/ManipulateAtomsProcess.cpp Actions/ActionRegistry.cpp
     11ACTIONSHEADER = Actions/Action.hpp Actions/Process.hpp Actions/Calculation.hpp Actions/Calculation_impl.hpp Actions/MethodAction.hpp Actions/ActionSequence.hpp Actions/MakroAction.hpp Actions/ErrorAction.hpp Actions/small_actions.hpp Actions/ManipulateAtomsProcess.hpp Actions/ActionRegistry.hpp
    1212
    1313PATTERNSOURCE = Patterns/Observer.cpp
  • src/World.cpp

    rb2cfdb r7c4e29  
    1313#include "Descriptors/AtomDescriptor.hpp"
    1414#include "Descriptors/AtomDescriptor_impl.hpp"
     15#include "Actions/ManipulateAtomsProcess.hpp"
    1516
    1617using namespace std;
     
    4748}
    4849
     50
     51ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name,AtomDescriptor descr){
     52  return new ManipulateAtomsProcess(op, descr,name,true);
     53}
     54
    4955/******************************* Iterators ********************************/
     56
     57World::AtomIterator::AtomIterator(){
     58  state = World::get()->atomEnd();
     59}
    5060
    5161World::AtomIterator::AtomIterator(AtomDescriptor _descr, World* _world) :
    5262    descr(_descr.get_impl()),
    53     world(_world)
     63    world(_world),
     64    index(0)
    5465{
    5566  state = world->atoms.begin();
     
    5970World::AtomIterator::AtomIterator(const AtomIterator& rhs) :
    6071    state(rhs.state),
    61     descr(rhs.descr)
     72    descr(rhs.descr),
     73    index(rhs.index),
     74    world(rhs.world)
    6275  {}
    6376
     77World::AtomIterator& World::AtomIterator::operator=(const AtomIterator& rhs)
     78{
     79  if(&rhs!=this){
     80    state=rhs.state;
     81    descr=rhs.descr;
     82    index=rhs.index;
     83    world=rhs.world;
     84  }
     85  return *this;
     86}
     87
    6488World::AtomIterator& World::AtomIterator::operator++(){
     89  ++state;
     90  ++index;
    6591  advanceState();
     92  return *this;
     93}
     94
     95World::AtomIterator World::AtomIterator::operator++(int){
     96  AtomIterator res(*this);
     97  ++(*this);
     98  return res;
    6699}
    67100
     
    70103}
    71104
     105bool World::AtomIterator::operator==(const World::AtomList::iterator& rhs){
     106  return state==rhs;
     107}
     108
    72109bool World::AtomIterator::operator!=(const AtomIterator& rhs){
    73110  return state!=rhs.state;
    74111}
    75112
     113bool World::AtomIterator::operator!=(const World::AtomList::iterator& rhs){
     114  return state!=rhs;
     115}
     116
    76117atom* World::AtomIterator::operator*(){
    77118  return (*state).second;
     
    79120
    80121void World::AtomIterator::advanceState(){
    81   while(state!=world->atoms.end() && !descr->predicate(*state))
    82     state++;
     122  while((state!=world->atoms.end()) && (!descr->predicate(*state))){
     123    ++state;
     124    ++index;
     125  }
     126}
     127
     128int World::AtomIterator::getCount(){
     129  return index;
    83130}
    84131
    85132World::AtomIterator World::getAtomIter(AtomDescriptor descr){
    86133  return AtomIterator(descr,this);
     134}
     135
     136World::AtomList::iterator World::atomEnd(){
     137  return atoms.end();
    87138}
    88139
     
    98149    dummyId(0),
    99150    periode(new periodentafel),
    100     molecules_deprecated(new MoleculeListClass)
     151    molecules_deprecated(new MoleculeListClass),
     152    atoms()
    101153{
    102154  molecules_deprecated->signOn(this);
  • src/World.hpp

    rb2cfdb r7c4e29  
    99#define WORLD_HPP_
    1010
    11 #include <boost/thread.hpp>
     11#include <string>
    1212#include <map>
    1313#include <vector>
    1414#include <set>
     15#include <boost/thread.hpp>
    1516#include <boost/shared_ptr.hpp>
     17
    1618
    1719#include "Patterns/Observer.hpp"
     
    2527class AtomDescriptor;
    2628class AtomDescriptor_impl;
     29class ManipulateAtomsProcess;
    2730
    2831class World : public Observable
     
    3033friend class AtomDescriptor_impl;
    3134friend class AtomDescriptor;
     35
     36friend class ManipulateAtomsProcess;
    3237
    3338typedef std::map<int,atom*> AtomList;
     
    4550  molecule *createMolecule();
    4651
     52  ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string,AtomDescriptor);
     53
    4754protected:
    4855  /**** Iterators to use internal data structures */
    4956  class AtomIterator {
    5057  public:
     58    AtomIterator();
    5159    AtomIterator(AtomDescriptor, World*);
    5260    AtomIterator(const AtomIterator&);
    53     AtomIterator& operator++();
     61    AtomIterator& operator=(const AtomIterator&);
     62    AtomIterator& operator++();     // prefix
     63    AtomIterator  operator++(int);  // postfix with dummy parameter
    5464    bool operator==(const AtomIterator&);
     65    bool operator==(const AtomList::iterator&);
    5566    bool operator!=(const AtomIterator&);
     67    bool operator!=(const AtomList::iterator&);
    5668    atom* operator*();
     69
     70    int getCount();
    5771  protected:
    5872    void advanceState();
     
    6074    AtomList::iterator state;
    6175    boost::shared_ptr<AtomDescriptor_impl>  descr;
     76    int index;
    6277  };
    6378
    6479  AtomIterator getAtomIter(AtomDescriptor descr);
     80  AtomList::iterator atomEnd();
    6581
    6682private:
  • src/unittests/Makefile.am

    rb2cfdb r7c4e29  
    3030  CacheableTest \
    3131  DescriptorUnittest \
     32  manipulateAtomsTest \
    3233  ${MENUTESTS} 
    3334   
     
    109110
    110111DescriptorUnittest_SOURCES = DescriptorUnittest.cpp DescriptorUnittest.hpp
    111 DescriptorUnittest_LDADD = ${ALLLIBS}
     112DescriptorUnittest_LDADD = ${ALLLIBS}
     113
     114manipulateAtomsTest_SOURCES = manipulateAtomsTest.cpp manipulateAtomsTest.hpp
     115manipulateAtomsTest_LDADD = ${ALLLIBS}
    112116
    113117#AUTOMAKE_OPTIONS = parallel-tests
Note: See TracChangeset for help on using the changeset viewer.