Ignore:
Timestamp:
Mar 4, 2010, 10:34:52 AM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
fe3540
Parents:
d50264 (diff), f058ef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'StructureRefactoring' into MenuRefactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/World.hpp

    rd50264 rdb6b872  
    2727class AtomDescriptor;
    2828class AtomDescriptor_impl;
     29class MoleculeDescriptor;
     30class MoleculeDescriptor_impl;
    2931class ManipulateAtomsProcess;
    3032template<typename T>
     
    3638friend class AtomDescriptor_impl;
    3739friend class AtomDescriptor;
     40friend class MoleculeDescriptor_impl;
     41friend class MoleculeDescriptor;
    3842
    3943// Actions, calculations etc associated with the World
     
    7781
    7882  /**
     83   * returns the first molecule that matches a given descriptor.
     84   * Do not rely on ordering for descriptors that match more than one molecule.
     85   */
     86  molecule *getMolecule(MoleculeDescriptor descriptor);
     87
     88  /**
     89   * returns a vector containing all molecules that match a given descriptor
     90   */
     91  std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor);
     92
     93  /**
    7994   * get the number of molecules in the World
    8095   */
     
    117132
    118133  /**
     134   * used when changing an atom Id.
     135   * Unless you are calling this method from inside an atom don't fiddle with the third parameter.
     136   *
     137   * Return value indicates wether the change could be done or not.
     138   */
     139  bool changeAtomId(atomId_t oldId, atomId_t newId, atom* target=0);
     140
     141  /**
    119142   * Produces a process that calls a function on all Atoms matching a given descriptor. The process is not
    120143   * called at this time, so it can be passed around, stored inside menuItems etc.
     
    125148protected:
    126149  /**** Iterators to use internal data structures */
     150
     151  // Atoms
     152
    127153  class AtomIterator {
    128154  public:
     
    163189  AtomSet::iterator atomEnd();
    164190
     191  // Molecules
     192
     193  class MoleculeIterator {
     194  public:
     195    MoleculeIterator();
     196    MoleculeIterator(MoleculeDescriptor, World*);
     197    MoleculeIterator(const MoleculeIterator&);
     198    MoleculeIterator& operator=(const MoleculeIterator&);
     199    MoleculeIterator& operator++();     // prefix
     200    MoleculeIterator  operator++(int);  // postfix with dummy parameter
     201    bool operator==(const MoleculeIterator&);
     202    bool operator==(const MoleculeSet::iterator&);
     203    bool operator!=(const MoleculeIterator&);
     204    bool operator!=(const MoleculeSet::iterator&);
     205    molecule* operator*();
     206
     207    int getCount();
     208  protected:
     209    void advanceState();
     210    MoleculeSet::iterator state;
     211    boost::shared_ptr<MoleculeDescriptor_impl>  descr;
     212    int index;
     213
     214    World* world;
     215  };
     216
     217  /**
     218   * returns an iterator over all Molecules matching a given descriptor.
     219   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
     220   */
     221  MoleculeIterator getMoleculeIter(MoleculeDescriptor descr);
     222
     223  /**
     224   * returns an iterator to the end of the MoleculeSet. Due to overloading this iterator
     225   * can be compared to iterators produced by getMoleculeIter (see the mis-matching types).
     226   * Thus it can be used to detect when such an iterator is at the end of the list.
     227   * used for internal purposes, like MoleculeProcesses and MoleculeCalculations.
     228   */
     229  MoleculeSet::iterator moleculeEnd();
     230
     231
    165232  /******* Internal manipulation routines for double callback and Observer mechanism ******/
    166233  void doManipulate(ManipulateAtomsProcess *);
    167234
    168235private:
     236
     237  atomId_t getNextAtomId();
     238  void releaseAtomId(atomId_t);
     239  bool reserveAtomId(atomId_t);
     240
    169241  periodentafel *periode;
    170242  AtomSet atoms;
     243  std::set<atomId_t> atomIdPool; //<!stores the pool for all available AtomIds below currAtomId
    171244  atomId_t currAtomId; //!< stores the next available Id for atoms
    172245  MoleculeSet molecules;
Note: See TracChangeset for help on using the changeset viewer.