Created
October 19, 2020 05:34
-
-
Save Cylix/05d4b823f2a61240205b34c5e515db4e to your computer and use it in GitHub Desktop.
Reflection in C++14 - Registration #2
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
class reflectable_base { | |
public: | |
virtual ~reflectable_base(void) = default; | |
virtual const std::string& get_name(void) const = 0; | |
}; | |
template <typename T> | |
class reflectable : reflectable_base { | |
public: | |
//! constructor of a reflectable class where we can process the registration | |
reflectable(const std::string& class_name) : 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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment