14 #ifndef GK_SCENEOBJECT_HPP_ 15 #define GK_SCENEOBJECT_HPP_ 19 #include <unordered_map> 30 template<
typename T,
typename... Args>
31 T &
set(Args &&...args) {
32 m_components[
typeid(T).hash_code()] = std::make_shared<T>(std::forward<Args>(args)...);
45 throw EXCEPTION(
"SceneObject", (
void*)
this,
"(\"" +
m_name +
"\", \"" +
m_type +
"\") doesn't have a component of type:",
typeid(T).
name());
48 return *std::static_pointer_cast<T>(it->second);
58 DEBUG(
"=== Component list of object:", (
void*)
this,
"===");
62 DEBUG(it.first,
":", (
void*)it.second.get());
65 DEBUG(
"=== End of list. ===");
81 #endif // GK_SCENEOBJECT_HPP_
const std::string & name() const
std::unordered_map< size_t, std::shared_ptr< void > > m_components
#define EXCEPTION(args...)
const std::string & type() const
SceneObject(const std::string &name="null", const std::string &type="null")