Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Dialog.cpp

    r163110 r37a67f  
    135135}*/
    136136
    137 template <> void Dialog::query<bool>(Parameter<bool> &param, const std::string title, const std::string description)
    138 {
    139   queryBoolean(param, title, description);
    140 }
     137/** With the following boost::preprocessor code we generate template
     138 * specializations for each desired query types in the abstract class Dialog.
     139 */
     140#include "UIElements/GlobalListOfParameterQueries.hpp"
     141#include "UIElements/Dialog_impl_pre.hpp"
    141142
    142 template <> void Dialog::query<int>(Parameter<int> &param, const std::string title, const std::string description)
    143 {
    144   queryInt(param, title, description);
    145 }
     143  // print a template body
     144  #define dialog_definition(z,n,TOKENLIST,TYPELIST) \
     145  template <> void Dialog::query< \
     146    BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     147  >(Parameter< \
     148    BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     149  > &param, const std::string title, const std::string description) { \
     150  BOOST_PP_CAT(query, BOOST_PP_SEQ_ELEM(n, TOKENLIST)) \
     151  (param, title, description); }
    146152
    147 template <> void Dialog::query< std::vector<int> >(Parameter<std::vector<int> > &param, const std::string title, const std::string description)
    148 {
    149   queryInts(param, title, description);
    150 }
     153  // print template specialization for every query type
     154  #if defined GLOBALLISTOFPARAMETERQUERIES_Token && defined GLOBALLISTOFPARAMETERQUERIES_Type
     155  #define BOOST_PP_LOCAL_MACRO(n) dialog_definition(~, n, GLOBALLISTOFPARAMETERQUERIES_Token, GLOBALLISTOFPARAMETERQUERIES_Type)
     156  #define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMETERTOKENS-1)
     157  #include BOOST_PP_LOCAL_ITERATE()
     158  #endif
    151159
    152 template <> void Dialog::query<unsigned int>(Parameter<unsigned int> &param, const std::string title, const std::string description)
    153 {
    154   queryUnsignedInt(param, title, description);
    155 }
     160  #undef dialog_definition
    156161
    157 template <> void Dialog::query< std::vector<unsigned int> >(Parameter<std::vector<unsigned int> > &param, const std::string title, const std::string description)
    158 {
    159   queryUnsignedInts(param, title, description);
    160 }
     162#include "Dialog_impl_undef.hpp"
     163/* End of preprocessor code piece */
    161164
    162 template <> void Dialog::query<double>(Parameter<double> &param, const std::string title, const std::string description)
    163 {
    164   queryDouble(param, title, description);
    165 }
    166 
    167 template <> void Dialog::query< std::vector<double> >(Parameter<std::vector<double> > &param, const std::string title, const std::string description)
    168 {
    169   queryDoubles(param, title, description);
    170 }
    171 
    172 template <> void Dialog::query<std::string>(Parameter<std::string> &param, const std::string title, const std::string description)
    173 {
    174   queryString(param, title, description);
    175 }
    176 
    177 template <> void Dialog::query< std::vector<std::string> >(Parameter<std::vector<std::string> > &param, const std::string title, const std::string description)
    178 {
    179   queryStrings(param, title, description);
    180 }
    181 
    182 template <> void Dialog::query<const atom *>(Parameter<const atom *> &param, const std::string title, const std::string description)
    183 {
    184   queryAtom(param, title, description);
    185 }
    186 
    187 template <> void Dialog::query< std::vector<const atom *> >(Parameter<std::vector<const atom *> > &param, const std::string title, const std::string description)
    188 {
    189   queryAtoms(param, title, description);
    190 }
    191 
    192 template <> void Dialog::query<const molecule *>(Parameter<const molecule *> &param, const std::string title, const std::string description)
    193 {
    194   queryMolecule(param, title, description);
    195 }
    196 
    197 template <> void Dialog::query< std::vector<const molecule *> >(Parameter<std::vector<const molecule *> > &param, const std::string title, const std::string description)
    198 {
    199   queryMolecules(param, title, description);
    200 }
    201 
    202 template <> void Dialog::query<Vector>(Parameter<Vector> &param, const std::string title, const std::string description)
    203 {
    204   queryVector(param, title, description);
    205 }
    206 
    207 template <> void Dialog::query< std::vector<Vector> >(Parameter<std::vector<Vector> > &param, const std::string title, const std::string description)
    208 {
    209   queryVectors(param, title, description);
    210 }
    211 
    212 template <> void Dialog::query<RealSpaceMatrix>(Parameter<RealSpaceMatrix> &param, const std::string title, const std::string description)
    213 {
    214   queryRealSpaceMatrix(param, title, description);
    215 }
    216 
    217 template <> void Dialog::query<const element *>(Parameter<const element *> &param, const std::string title, const std::string description)
    218 {
    219   queryElement(param, title, description);
    220 }
    221 
    222 template <> void Dialog::query< std::vector<const element *> >(Parameter<std::vector<const element *> > &param, const std::string title, const std::string description)
    223 {
    224   queryElements(param, title, description);
    225 }
    226 
    227 template <> void Dialog::query< boost::filesystem::path >(Parameter<boost::filesystem::path> &param, const std::string title, const std::string description)
    228 {
    229   queryFile(param, title, description);
    230 }
    231 
    232 template <> void Dialog::query< std::vector<boost::filesystem::path> >(Parameter<std::vector< boost::filesystem::path> > &param, const std::string title, const std::string description)
    233 {
    234   queryFiles(param, title, description);
    235 }
    236 
    237 template <> void Dialog::query< RandomNumberDistribution_Parameters >(Parameter<RandomNumberDistribution_Parameters> &param, const std::string title, const std::string description)
    238 {
    239   queryRandomNumberDistribution_Parameters(param, title, description);
    240 }
     165//template <> void Dialog::query< std::vector<KeyValuePair> >(Parameter< std::vector<KeyValuePair> > &param, const std::string title, const std::string description)
     166//{
     167//  queryKeyValuePairs(param, title, description);
     168//}
    241169
    242170/************************** Query Infrastructure ************************/
Note: See TracChangeset for help on using the changeset viewer.