source: src/RandomNumbers/EmptyPrototypeTable.hpp@ 3f6aac

Action_Thermostats Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator EmpiricalPotential_contain_HomologyGraph_documentation Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_Verbose_Codepatterns ForceAnnealing_oldresults ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters Recreated_GuiChecks StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps
Last change on this file since 3f6aac was c9bc2b7, checked in by Frederik Heber <heber@…>, 14 years ago

Bigger rewrite of RandomNumbers ... due to cloning of prototypes.

  • in order to copy the prototypes and not use the original instance, we have implemented a new pattern called "Creator" that wraps a templated class in a creation interface class such that this abstract class can instaniate the particular types (see here http://stackoverflow.com/questions/3506026/c-clone-abstract-base-class-without-meddling-with-derived). This is also wrapped up in ..._Creator.hpp files.
  • meanwhile we also tried to have factories for Engine and Distribution but this failed due to boost::variate_operator<> having to know the particular types of engine and distribution. One could go forth with some cast's but this is very unclean and not what we want. ... Downside is that we can't set global options for engines or distributions as of now.
  • For the moment Engine- and DistributionFactory both have a prototype table, i.e. the same wrapped ones as above, but they are not used for the GeneratorFactory.
  • Property mode set to 100644
File size: 798 bytes
Line 
1/*
2 * EmptyPrototypeTable.hpp
3 *
4 * Created on: Jan 3, 2011
5 * Author: heber
6 */
7
8#ifndef EMPTYPROTOTYPETABLE_HPP_
9#define EMPTYPROTOTYPETABLE_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16/** Removes all pointers to instances from a table while free'ing memory.
17 *
18 * I.e. we assume class T to be a map of some key with its values pointers to
19 * some classes that have to be free'd.
20 *
21 * \param _PrototypeTable table to empty
22 */
23template <class T>
24void EmptyPrototypeTable(T &_PrototypeTable)
25{
26 for (typename T::iterator iter = _PrototypeTable.begin();
27 !_PrototypeTable.empty();
28 iter = _PrototypeTable.begin()) {
29 delete (iter->second);
30 _PrototypeTable.erase(iter);
31 }
32 _PrototypeTable.clear();
33}
34
35
36#endif /* EMPTYPROTOTYPETABLE_HPP_ */
Note: See TracBrowser for help on using the repository browser.