1 #ifndef BASE_OBJECT_HPP
2 #define BASE_OBJECT_HPP
6 #include <unordered_map>
7 #include <initializer_list>
13 #include "delta_mergable.hpp"
14 #include "base_game.hpp"
22 Base_object(std::initializer_list<std::pair<std::string, Any&&>> init);
32 std::shared_ptr<typename T::element_type>
as()
34 auto&
self = get_game()->get_objects()[get_id()];
35 return std::dynamic_pointer_cast<
typename T::element_type>(
self);
45 return (this->as<T>() !=
nullptr);
50 virtual void resize(
const std::string& name, std::size_t size)
override {}
51 virtual void change_vec_values(
const std::string& name,
52 std::vector<std::pair<std::size_t, Any>>& values)
override {}
53 virtual void remove_key(
const std::string& name, Any& key)
override {}
54 virtual std::unique_ptr<Any>
55 add_key_value(
const std::string& name, Any& key, Any& value)
override;
56 virtual bool is_map(
const std::string& name)
override {
return false; }
57 virtual Base_game* get_game() {
return nullptr; }
58 virtual void rebind_by_name(Any* to_change,
const std::string& member, std::shared_ptr<Base_object> ref)
override {}
63 const std::string& get_id() const noexcept;
68 #endif // BASE_OBJECT_HPP
Definition: base_object.hpp:19
bool is()
Determines if this object is of the specified object type
Definition: base_object.hpp:43
std::shared_ptr< typename T::element_type > as()
Dynamically casts this object to another type. Returns nullptr if it cannot be converted to the type...
Definition: base_object.hpp:32