Files
build/tools/aconfig/templates/cpp_exported_header.template
Dennis Shen 5c2421394c Minor c/c++ codegen update
1, Moved "#include <string>" from exported header to test flag provider
header file.

2, For production target and read only flags, the generated c
api should just return default value instead of calling into c++ api

3, Remove using namespace server_configurable_flags from header, instead
of just having the namespace to be spelled out in each api call. Having
using namespace xxx in header is not a c++ best practice.

4, Replace #ifdef #def #endif with #pragma once

Bug: b/279483801
Test: atest aconfig.test
Change-Id: I3e55a7b14301f3de419795467f33e2dc889d371e
2023-07-14 16:09:35 +00:00

51 lines
1013 B
Plaintext

#pragma once
#include <memory>
namespace {cpp_namespace} \{
class flag_provider_interface \{
public:
virtual ~flag_provider_interface() = default;
{{ for item in class_elements}}
virtual bool {item.flag_name}() = 0;
{{ if for_test }}
virtual void {item.flag_name}(bool val) = 0;
{{ -endif }}
{{ endfor }}
{{ if for_test }}
virtual void reset_flags() \{}
{{ -endif }}
};
extern std::unique_ptr<flag_provider_interface> provider_;
{{ for item in class_elements}}
inline bool {item.flag_name}() \{
{{ if for_test }}
return provider_->{item.flag_name}();
{{ -else- }}
{{ if not item.readwrite- }}
return {item.default_value};
{{ -else- }}
return provider_->{item.flag_name}();
{{ -endif }}
{{ -endif }}
}
{{ if for_test }}
inline void {item.flag_name}(bool val) \{
provider_->{item.flag_name}(val);
}
{{ -endif }}
{{ endfor }}
{{ if for_test }}
inline void reset_flags() \{
return provider_->reset_flags();
}
{{ -endif }}
}