Ignore:
Timestamp:
Feb 18, 2010, 1:21:35 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
cbc27f
Parents:
b53a7e
Message:

Added iterator structure that allows iterating over selected atoms in the World.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/World.hpp

    rb53a7e ra5471c  
    1313#include <vector>
    1414#include <set>
     15#include <boost/shared_ptr.hpp>
    1516
    1617#include "Patterns/Observer.hpp"
     
    2829{
    2930friend class AtomDescriptor_impl;
     31friend class AtomDescriptor;
     32
     33typedef std::map<int,atom*> AtomList;
    3034public:
    3135
     
    4044  /***** Methods to work with the World *****/
    4145  molecule *createMolecule();
     46
     47protected:
     48  /**** Iterators to use internal data structures */
     49  class AtomIterator {
     50  public:
     51    AtomIterator(AtomDescriptor, World*);
     52    AtomIterator(const AtomIterator&);
     53    AtomIterator& operator++();
     54    bool operator==(const AtomIterator&);
     55    bool operator!=(const AtomIterator&);
     56    atom* operator*();
     57  protected:
     58    void advanceState();
     59    World* world;
     60    AtomList::iterator state;
     61    boost::shared_ptr<AtomDescriptor_impl>  descr;
     62  };
     63
     64  AtomIterator getAtomIter(AtomDescriptor descr);
     65
    4266private:
    4367  periodentafel *periode;
    44   std::map<int,atom*> atoms;
     68  AtomList atoms;
    4569  std::set<molecule*> molecules;
    4670
Note: See TracChangeset for help on using the changeset viewer.