diff --git a/tools/aconfig/src/codegen_cpp.rs b/tools/aconfig/src/codegen_cpp.rs index 2c32bb04c3..37b058df4f 100644 --- a/tools/aconfig/src/codegen_cpp.rs +++ b/tools/aconfig/src/codegen_cpp.rs @@ -134,18 +134,12 @@ mod tests { namespace com::example { - class my_flag_one { - public: - virtual const bool value() { - return false; - } + static const bool my_flag_one() { + return false; } - class my_flag_two { - public: - virtual const bool value() { - return true; - } + static const bool my_flag_two() { + return true; } } @@ -201,24 +195,18 @@ mod tests { namespace com::example { - class my_flag_one { - public: - virtual const bool value() { - return GetServerConfigurableFlag( - "ns", - "com.example.my_flag_one", - "false") == "true"; - } + static const bool my_flag_one() { + return GetServerConfigurableFlag( + "ns", + "com.example.my_flag_one", + "false") == "true"; } - class my_flag_two { - public: - virtual const bool value() { - return GetServerConfigurableFlag( - "ns", - "com.example.my_flag_two", - "true") == "true"; - } + static const bool my_flag_two() { + return GetServerConfigurableFlag( + "ns", + "com.example.my_flag_two", + "true") == "true"; } } diff --git a/tools/aconfig/templates/cpp.template b/tools/aconfig/templates/cpp.template index 93f9b803e0..aa36d94ce4 100644 --- a/tools/aconfig/templates/cpp.template +++ b/tools/aconfig/templates/cpp.template @@ -6,18 +6,15 @@ using namespace server_configurable_flags; {{ endif }} namespace {cpp_namespace} \{ {{ for item in class_elements}} - class {item.flag_name} \{ - public: - virtual const bool value() \{ - {{ if item.readwrite- }} - return GetServerConfigurableFlag( - "{item.device_config_namespace}", - "{item.device_config_flag}", - "{item.default_value}") == "true"; - {{ -else- }} - return {item.default_value}; - {{ -endif }} - } + static const bool {item.flag_name}() \{ + {{ if item.readwrite- }} + return GetServerConfigurableFlag( + "{item.device_config_namespace}", + "{item.device_config_flag}", + "{item.default_value}") == "true"; + {{ -else- }} + return {item.default_value}; + {{ -endif }} } {{ endfor }} }