@@ -44,8 +44,8 @@ namespace ePhotosynthesis {
4444#define DO_VALUE_SET_CHILD_CLASSES_MACRO (macro, iter, ...) \
4545 if (!noChildren) { \
4646 size_t iChild = 0 ; \
47- for (std::vector<ValueSetClassWrapper>::iter it = child_classes.begin (); \
48- it != child_classes.end (); it++, iChild++) { \
47+ for (std::vector<ValueSetClassWrapper>::iter it = BaseClass:: child_classes.begin (); \
48+ it != BaseClass:: child_classes.end (); it++, iChild++) { \
4949 if (*it) { \
5050 macro ((*it), __VA_ARGS__); \
5151 } \
@@ -714,7 +714,7 @@ namespace ePhotosynthesis {
714714 Untemplated base class to allow storage of mixed value sets in
715715 containers.
716716 */
717- class ValueSet_t {
717+ class EPHOTO_API ValueSet_t {
718718 public:
719719
720720 virtual ~ValueSet_t () {}
@@ -889,7 +889,7 @@ namespace ePhotosynthesis {
889889 will be used by.
890890 */
891891 template <class T , class U , MODULE ID, PARAM_TYPE PT>
892- class ValueSetBase : public ValueSetEnum <ID, PT> {
892+ class EPHOTO_API ValueSetBase : public ValueSetEnum<ID, PT> {
893893 public:
894894 typedef T ThisClass; /* * Inheriting class */
895895 typedef U ThisParent; /* * Parent class */
@@ -1097,6 +1097,14 @@ namespace ePhotosynthesis {
10971097 print_value (val, out, show_pointers);
10981098 return std::move (out).str ();
10991099 }
1100+ /* *
1101+ Get a string containing a certain number of tabs.
1102+ \param[in] tab Number of tabs to include.
1103+ \returns String containing tabs.
1104+ */
1105+ static std::string getTabs (const uint tab = 0 ) {
1106+ return std::string (tab * tab_size, ' ' );
1107+ }
11001108 /* *
11011109 Display a single value from a value map.
11021110 \tparam V Type of value in value map.
@@ -1129,7 +1137,7 @@ namespace ePhotosynthesis {
11291137 if ((!includeSkipped) && (isSkipped (key) ||
11301138 isConstant (key)))
11311139 return out;
1132- const std::string space (tab * tab_size, ' ' );
1140+ const std::string space = getTabs (tab );
11331141 std::string iname;
11341142 if (includePrefixes)
11351143 iname = getNameWithPrefix (key);
@@ -2401,12 +2409,14 @@ namespace ePhotosynthesis {
24012409 child_classes.emplace_back (new ValueSetClassType<C>());
24022410 }
24032411
2412+ protected:
24042413 static int static_flags; /* *< Bitwise flags describing the value set static state */
24052414 static std::map<EnumType, double > defaults; /* *< Default values */
24062415 static std::map<EnumType, double *> static_values; /* *< Static values */
24072416 static std::vector<ValueSetClassWrapper> child_classes; /* *< Child classes */
24082417 static const uint tab_size = 2 ;
24092418
2419+ public:
24102420 // Methods that call inheriting class methods
24112421 /* *
24122422 Initialize the child classes.
@@ -2460,6 +2470,13 @@ namespace ePhotosynthesis {
24602470 if (!(static_flags & VS_FLAG_SELECTED))
24612471 ERROR_VALUE_SET (" Value set has not been selected" );
24622472 }
2473+ /* *
2474+ Check if the value set has children.
2475+ \returns true if the value set has children, false otherwise.
2476+ */
2477+ static bool hasChildren () {
2478+ return (child_classes.size () > 0 );
2479+ }
24632480 /* *
24642481 Check if the value set uses the C3 defaults.
24652482 \returns true if the C3 defaults are being used, false otherwise.
@@ -3220,6 +3237,7 @@ namespace ePhotosynthesis {
32203237 children.push_back (C);
32213238 }
32223239
3240+ private:
32233241 int flags = 0 ; /* *< Bitwise flags describing the value set */
32243242 std::map<EnumType, double *> values; /* *< Values in the set. */
32253243 std::map<EnumType, double > preinit_values; /* *< Value set pre-initialization */
@@ -3266,7 +3284,7 @@ namespace ePhotosynthesis {
32663284 ENSURE_VALUE_POINTERS_CONST;
32673285 uint child_tab = tab;
32683286 if (!(noChildren || includePrefixes)) {
3269- const std::string space (tab * BaseClass::tab_size, ' ' );
3287+ const std::string space = BaseClass::getTabs (tab );
32703288 out << space << error_prefix () << std::endl;
32713289 child_tab++;
32723290 }
@@ -3355,7 +3373,7 @@ namespace ePhotosynthesis {
33553373 }
33563374 BaseClass::import_value_map (values, map, CONTEXT_VALUE_SET);
33573375 if (setinit)
3358- static_flags |= BaseClass::VS_FLAG_INIT_VALUES;
3376+ BaseClass:: static_flags |= BaseClass::VS_FLAG_INIT_VALUES;
33593377 }
33603378
33613379 /* * \copydoc ValueSet::initMembers */
@@ -3371,11 +3389,11 @@ namespace ePhotosynthesis {
33713389 reset_value_map (values);
33723390 T::_resetValues ();
33733391 DO_VALUE_SET_CHILD_CLASSES (resetValues, ());
3374- static_flags &= ~BaseClass::VS_FLAG_INIT_VALUES;
3392+ BaseClass:: static_flags &= ~BaseClass::VS_FLAG_INIT_VALUES;
33753393 }
33763394 /* * \copydoc ValueSet::initialized */
33773395 static bool initialized () {
3378- return (static_flags & BaseClass::VS_FLAG_INIT_VALUES);
3396+ return (BaseClass:: static_flags & BaseClass::VS_FLAG_INIT_VALUES);
33793397 }
33803398 /* * \copydoc ValueSet::initValues */
33813399 static void initValues (const bool noDefaults=false ,
@@ -3386,21 +3404,25 @@ namespace ePhotosynthesis {
33863404 if (!noDefaults)
33873405 init_value_map (values, initialized ());
33883406 T::_initValues ();
3407+ // if (!noChildren) {
3408+ // ERROR_VALUE_SET("recursion for child classes disabled.");
3409+ // }
33893410 DO_VALUE_SET_CHILD_CLASSES (initValues, (noDefaults, force));
33903411 if (!preinit_values.empty ()) {
33913412 copy_value_map (values, preinit_values, " initValues: " ,
33923413 false , true , true , false , true );
33933414 }
3394- static_flags |= BaseClass::VS_FLAG_INIT_VALUES;
3415+ BaseClass:: static_flags |= BaseClass::VS_FLAG_INIT_VALUES;
33953416 }
33963417
33973418 /* * \copydoc ValueSet::initMemberPointers */
33983419 static void initMemberPointers (const bool noChildren=false ) {
3399- if (static_flags & BaseClass::VS_FLAG_INIT_POINTERS) return ;
3420+ if (BaseClass::static_flags & BaseClass::VS_FLAG_INIT_POINTERS)
3421+ return ;
34003422 BaseClass::initDefaults ();
34013423 T::_initMemberPointers ();
34023424 DO_VALUE_SET_CHILD_CLASSES (initMemberPointers, ());
3403- static_flags |= BaseClass::VS_FLAG_INIT_POINTERS;
3425+ BaseClass:: static_flags |= BaseClass::VS_FLAG_INIT_POINTERS;
34043426 }
34053427 /* * \copydoc ValueSetBase::initStaticMembers */
34063428 static void initStaticMembers (const bool noChildren = false ) {
@@ -3670,9 +3692,10 @@ namespace ePhotosynthesis {
36703692 */
36713693 template <typename C>
36723694 static void addChildClass () {
3673- child_classes.push_back (new ValueSetStaticClassType<C>());
3695+ BaseClass:: child_classes.push_back (new ValueSetStaticClassType<C>());
36743696 }
36753697
3698+ private:
36763699 static std::map<EnumType, double *> values; /* *< Values in the set. */
36773700 static std::map<EnumType, double > preinit_values; /* *< Value set pre-initialization */
36783701
@@ -3701,7 +3724,7 @@ namespace ePhotosynthesis {
37013724 ENSURE_VALUE_POINTERS;
37023725 uint child_tab = tab;
37033726 if (!(noChildren || includePrefixes)) {
3704- const std::string space (tab * BaseClass::tab_size, ' ' );
3727+ const std::string space = BaseClass::getTabs (tab );
37053728 out << space << error_prefix () << std::endl;
37063729 child_tab++;
37073730 }
0 commit comments