CombiningParticlePotentialParsing
Last change
on this file since ff4fff9 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.
- For all we have written unit tests:
|
-
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 | */
|
---|
23 | template <class T>
|
---|
24 | void 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.