Created
October 19, 2020 05:39
-
-
Save Cylix/6364870accd50c102238c8cc6475481c to your computer and use it in GitHub Desktop.
Reflection in C++14 - Member Function #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class reflectable : reflectable_base { | |
public: | |
//! constructor of a reflectable class where we can process the registration | |
//! note the presence of variadic template to accept any number of member functions | |
template <typename... Fcts> | |
reflectable(const std::string& class_name, Fcts... fcts) : name(class_name) { | |
reflection_manager::get_instance().register_reflectable(*this); | |
} | |
//! function to get reflectable name | |
const std::string& get_name(void) const { | |
return this->name; | |
} | |
private: | |
std::string name; | |
}; | |
static reflectable<SomeClass> register_some_class("SomeClass", | |
std::make_pair(std::string("some_fct_1"), &SomeClass::some_fct_1), | |
std::make_pair(std::string("some_fct_2"), &SomeClass::some_fct_2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment