source: src/RandomNumbers/TemplatePowerSetGenerator.hpp@ 30c753

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 30c753 was 1d5a871, checked in by Frederik Heber <heber@…>, 14 years ago

Factored out Factory pattern (no pun intended).

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*
2 * TemplatePowerSetGenerator.hpp
3 *
4 * Created on: Dec 31, 2010
5 * Author: heber
6 */
7
8#ifndef TEMPLATEPOWERSETGENERATOR_HPP_
9#define TEMPLATEPOWERSETGENERATOR_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
17// this include is needed for BOOST_PP_LOCAL_ITERATE()
18#include <boost/preprocessor/iteration/local.hpp>
19
20// this include is needed for BOOST_PP_REPEAT
21#include <boost/preprocessor/repetition/repeat.hpp>
22
23#include <boost/preprocessor/punctuation/comma_if.hpp>
24#include <boost/preprocessor/seq/elem.hpp>
25#include <boost/preprocessor/seq/enum.hpp>
26#include <boost/preprocessor/seq/for_each.hpp>
27#include <boost/preprocessor/seq/for_each_i.hpp>
28#include <boost/preprocessor/stringize.hpp>
29#include <boost/preprocessor/tuple/elem.hpp>
30
31/** Functions that prints the given elem as [elem].
32 *
33 * Use the funcione as follows:
34 * SquareBracketize(~,~,test)
35 *
36 * which would output:
37 * [test]
38 */
39#define SquareBracketize(r, data, i, elem) \
40[ \
41BOOST_PP_SEQ_ELEM(i, data) \
42elem \
43]
44
45/** Functions that allows to print a given seq of elements in the way of
46 * enumeration declaration.
47 *
48 * Use the functions as follows:
49 * #define BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(seq), n, seqitems_as_struct)
50 *
51 * where "seq" is your defined list, e.g.
52 * #define seq (1)(2)(3)(4)
53 *
54 * which would output:
55 * 1,
56 * 2,
57 * 3,
58 * 4
59 *
60 */
61#define seqitems_as_enum(z,n,seq_with_elements) \
62 BOOST_PP_COMMA_IF (n) \
63 BOOST_PP_SEQ_ELEM(n, seq_with_elements)
64
65/** Functions that allows to print a given seq of elements in the way of
66 * variable declaration.
67 *
68 * Use the functions as follows:
69 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum(seqsize, n, seq)
70 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seq)-1 )
71 * #include BOOST_PP_LOCAL_ITERATE()
72 *
73 * where "seq" is your defined list, e.g.
74 * #define seq (1)(2)(3)(4)
75 *
76 * which would output:
77 * 1;
78 * 2;
79 * 3;
80 * 4;
81 *
82 */
83#define seqitems_as_struct(z,n,seq_with_elements ) \
84 BOOST_PP_SEQ_ELEM(n, seq_with_elements) ;
85
86/** Functions that allows to print a given seq of elements in the way of
87 * std::map from strings to enums.
88 *
89 * e.g. let "seq" be defined as
90 * #define seq (one)(two)(three)(four)
91 *
92 * then we use
93 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(seqsize, n, seq, EnumMap, name_space)
94 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seq)-1 )
95 * #include BOOST_PP_LOCAL_ITERATE()
96 *
97 * which expands by the preprocessor to:
98 * EnumMap["one"] = test:: one;
99 * EnumMap["two"] = test:: two;
100 * EnumMap["three"] = test:: three;
101 * EnumMap["four"] = test:: four;
102
103 */
104#define seqitems_as_string_enum_map(z,n,seq_with_elements, map, name_space) \
105 map [BOOST_PP_STRINGIZE( \
106 BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
107 )] = name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
108 ;
109
110/** Functions that allows to print a given seq of elements in the way of
111 * std::map from strings to enums.
112 *
113 * e.g. let "seq" be defined as
114 * #define seq (one)(two)(three)(four)
115 *
116 * then we use
117 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(seqsize, n, seq, EnumMap, test::)
118 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seq)-1 )
119 * #include BOOST_PP_LOCAL_ITERATE()
120 *
121 * which expands by the preprocessor to:
122 * EnumMap[one] = test::one;
123 * EnumMap[two] = test::two;
124 * EnumMap[three] = test::three;
125 * EnumMap[four] = test::four;
126
127 */
128#define seqitems_as_enum_key_map(z,n,seq_with_elements, map, keytype, name_space, suffix) \
129 map [ \
130 BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
131 ] = keytype< name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) suffix > ();
132
133#define tupel_in_square_brackets(z,n,tupelelement) \
134[ \
135tupelelement \
136]\
137
138/** Functions that allows to print a given seq of elements in the way of
139 * std::map from strings to enums.
140 *
141 * e.g. let "seqseq" be defined as
142 * #define seqseq ((d)(eins)(zwei)(drei))((e)(one)(two)(three))((f)(un)(deux)(troix))
143 *
144 * then we use
145 * #define tableprinter(z,n,seq) BOOST_PP_SEQ_ELEM(n,seq)
146 * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_multidimmap(seqsize, n, seqseq, bla::, MultiMap, test::testfunction, test_printer, tableprinter)
147 * #define BOOST_PP_LOCAL_LIMITS (0, BOOST_PP_SEQ_SIZE(seqseq)-1 )
148 * #include BOOST_PP_LOCAL_ITERATE()
149 *
150 * which expands by the preprocessor to:
151 * MultiMap[eins][zwei][drei] = test:: d;
152 * MultiMap[one][two][three] = test:: e;
153 * MultiMap[un][deux][troix] = test:: f;
154
155 */
156#define seqitems_as_enum_key_multidimmap(z,n, size_tupels, seq_of_tupels, map, tableitems_arg_printer, template_function, template_arg_printer, param_arg_printer) \
157 map \
158 BOOST_PP_REPEAT (size_tupels, tableitems_arg_printer, BOOST_PP_SEQ_ELEM(n, seq_of_tupels) ) \
159 = template_function \
160 < BOOST_PP_REPEAT(size_tupels, template_arg_printer, BOOST_PP_SEQ_ELEM(n, seq_of_tupels) ) > (\
161 BOOST_PP_REPEAT(size_tupels, param_arg_printer, BOOST_PP_SEQ_ELEM(n, seq_of_tupels) ) );
162
163
164#endif /* TEMPLATEPOWERSETGENERATOR_HPP_ */
Note: See TracBrowser for help on using the repository browser.