Changeset 5bf941 for molecuilder


Ignore:
Timestamp:
Feb 24, 2010, 4:44:58 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
e7e088
Parents:
7bfc19
Message:

Improved documentation of the World-class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/World.hpp

    r7bfc19 r5bf941  
    4646  /***** getter and setter *****/
    4747  // reference to pointer is used for legacy reason... reference will be removed latter to keep encapsulation of World object
     48  /**
     49   * returns the periodentafel for the world.
     50   */
    4851  periodentafel *&getPeriode();
     52
     53  /**
     54   * returns the first atom that matches a given descriptor.
     55   * Do not rely on ordering for descriptors that match more than one atom.
     56   */
    4957  atom* getAtom(AtomDescriptor descriptor);
     58
     59  /**
     60   * returns a vector containing all atoms that match a given descriptor
     61   */
    5062  std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
    5163
     64  /**
     65   * returns a calculation that calls a given function on all atoms matching a descriptor.
     66   * the calculation is not called at this point and can be used as an action, i.e. be stored in
     67   * menus, be kept around for later use etc.
     68   */
    5269  template<typename T>
    5370  AtomsCalculation<T>* calcOnAtoms(boost::function<T(atom*)>,std::string,AtomDescriptor);
    5471
     72  /**
     73   * get the number of atoms in the World
     74   */
    5575  int numAtoms();
     76
     77  /**
     78   * get the number of molecules in the World
     79   */
    5680  int numMolecules();
    5781
    5882  /***** Methods to work with the World *****/
     83
     84  /**
     85   * create a new molecule. This method should be used whenever any kind of molecule is needed. Assigns a unique
     86   * ID to the molecule and stores it in the World for later retrieval. Do not create molecules directly.
     87   */
    5988  molecule *createMolecule();
     89
     90  /**
     91   * Create a new atom. This method should be used whenever any atom is needed. Assigns a unique ID and stores
     92   * the atom in the World. If the atom is not destroyed it will automatically be destroyed when the world ends.
     93   */
    6094  atom *createAtom();
     95
     96  /**
     97   * Registers a Atom unknown to world. Needed in some rare cases, e.g. when cloning atoms, or in some unittests.
     98   * Do not re-register Atoms already known to the world since this will cause double-frees.
     99   */
    61100  int registerAtom(atom*);
     101
     102  /**
     103     * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on
     104     * atom directly since this will leave the pointer inside the world.
     105   */
    62106  void destroyAtom(atom*);
     107
     108  /**
     109   * Delete some atom and erase it from the world. Use this whenever you need to destroy any atom. Do not call delete on
     110   * atom directly since this will leave the pointer inside the world.
     111   */
    63112  void destroyAtom(int);
    64113
     114  /**
     115   * Produces a process that calls a function on all Atoms matching a given descriptor. The process is not
     116   * called at this time, so it can be passed around, stored inside menuItems etc.
     117   */
    65118  ManipulateAtomsProcess* manipulateAtoms(boost::function<void(atom*)>,std::string,AtomDescriptor);
    66119
     
    90143  };
    91144
     145  /**
     146   * returns an iterator over all Atoms matching a given descriptor.
     147   * used for internal purposes, like AtomProcesses and AtomCalculations.
     148   */
    92149  AtomIterator getAtomIter(AtomDescriptor descr);
     150
     151  /**
     152   * returns an iterator to the end of the AtomList. Due to overloading this iterator
     153   * can be compared to iterators produced by getAtomIter (see the mis-matching types).
     154   * Thus it can be used to detect when such an iterator is at the end of the list.
     155   * used for internal purposes, like AtomProcesses and AtomCalculations.
     156   */
    93157  AtomList::iterator atomEnd();
    94158
     
    105169  /***** singleton Stuff *****/
    106170public:
     171
     172  /**
     173   * get the currently active instance of the World.
     174   */
    107175  static World* get();
     176
     177  /**
     178   * destroy the currently active instance of the World.
     179   */
    108180  static void destroy();
     181
     182  /**
     183   * destroy the currently active instance of the World and immidiately
     184   * create a new one. Use this to reset while somebody is still Observing
     185   * the world and should reset the observed instance. All observers will be
     186   * sent the subjectKille() message from the old world.
     187   */
    109188  static World* reset();
    110189
    111190private:
     191  /**
     192   * private constructor to ensure creation of the world using
     193   * the singleton pattern.
     194   */
    112195  World();
     196
     197  /**
     198   * private destructor to ensure destruction of the world using the
     199   * singleton pattern.
     200   */
    113201  virtual ~World();
    114202
Note: See TracChangeset for help on using the changeset viewer.