Skip to content

Commit

Permalink
more option checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gf712 committed Feb 23, 2019
1 parent 8df33da commit 38abdf7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/shogun/base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,27 @@
{ \
static_assert( \
std::is_enum<decltype(enum_value)>::value, "Expected an enum!"); \
m_string_to_enum_map[param_name][VALUE_TO_STRING_MACRO(enum_value)] = \
enum_value; \
}

#define SG_ADD_OPTION0() \
{ \
static_assert(false, "No arguments provided"); \
if (has(param_name)) \
{ \
m_string_to_enum_map[param_name] \
[VALUE_TO_STRING_MACRO(enum_value)] = \
enum_value; \
} \
else \
{ \
SG_ERROR( \
"Register parameter %s::%s with SG_ADD before adding options", \
get_name(), param_name); \
} \
try \
{ \
get<machine_int_t>(param_name); \
} \
catch (ShogunException&) \
{ \
SG_ERROR( \
"Only parameters of type machine_int_t can have options"); \
} \
}

#define SG_ADD_OPTION1(param_name) \
Expand Down

0 comments on commit 38abdf7

Please sign in to comment.