Loading...
Searching...
No Matches
bbm_fromstring.h
Go to the documentation of this file.
1/************************************************************************/
2/*! \file bbm_fromstring.h
3 \brief fromString support for BBM
4
5 Export bbm::fromString<BsdfMOdel> method calls to a named tuple with the
6 name set to BsdfModel::name.
7
8 \param BsdfModel = the class name of the BSDF model to create a fromString handle for
9
10 Assumes that:
11
12 1. a bbm::fromString<BsdfModel> specialization exists for BsdfModel, either
13 by using the default constructor (constructor_args_t is defined), or by a
14 specialized static BsdfModel::fromString method.
15
16 2. a BsdfModel::name static constexpr string_literal exists
17
18 3. the BsdfModel takes a single template parameter that is the
19 configuration. Furthermore, we assume that a typedef Config exists.
20
21 The macro will construct a named tuple with a single name (the
22 BsdfModel::name), and a function pointer to the corresponding
23 bbm::fromString<BsdfModel> specialization as value.
24
25 Note: the creation of the named tuple is followed by a comma, not a semi
26 comma. It is expected that all named tuples from the different bsdfmodel are
27 then concat in a single tuple. See bsdf_ptr for it usage. Example:
28
29 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.c}
30 auto bsdf_fromString = named_cat(
31 #include "bbm_bsdfmodels.h"
32 make_named<"dummy">(null_ptr)
33 );
34
35 auto Bsdf = bbm::get<"Lambertian">(bsdf_fromString)("Lambertian([1,1,1])");
36 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
38 This example will create a bsdf_fromString named tuple, where the names are
39 the bsdfmodel names, and the values are function pointers to the
40 corresponding fromString method. The second line passes a string to the
41 fromString method that corresponds to the Lambertian bsdfmodel.
42
43 Note: because each entry ends with a comma, we need to add one 'dummy' entry
44 to close the list of named tuples.
45
46*************************************************************************/
47
48#undef BBM_EXPORT_BSDFMODEL
49#define BBM_EXPORT_BSDFMODEL(BsdfModel) make_named<BsdfModel<Config>::name>( bbm::fromString<BsdfModel<Config>> ),