mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-07 12:31:49 +02:00
Simplified ObjectDB::get_instance()
casting
Reduces boiler plate by templating `get_instance()` for the cast type, while remaining backward compatible to the existing functionality.
This commit is contained in:
parent
ae19a49a1e
commit
dedeec9492
@ -2043,6 +2043,7 @@ void ObjectDB::remove_instance(Object *p_object) {
|
|||||||
|
|
||||||
rw_lock.write_unlock();
|
rw_lock.write_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *ObjectDB::get_instance(ObjectID p_instance_id) {
|
Object *ObjectDB::get_instance(ObjectID p_instance_id) {
|
||||||
rw_lock.read_lock();
|
rw_lock.read_lock();
|
||||||
Object **obj = instances.getptr(p_instance_id);
|
Object **obj = instances.getptr(p_instance_id);
|
||||||
|
@ -856,6 +856,12 @@ public:
|
|||||||
typedef void (*DebugFunc)(Object *p_obj);
|
typedef void (*DebugFunc)(Object *p_obj);
|
||||||
|
|
||||||
static Object *get_instance(ObjectID p_instance_id);
|
static Object *get_instance(ObjectID p_instance_id);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
static T *get_instance(ObjectID p_instance_id) {
|
||||||
|
return Object::cast_to<T>(get_instance(p_instance_id));
|
||||||
|
}
|
||||||
|
|
||||||
static void debug_objects(DebugFunc p_func);
|
static void debug_objects(DebugFunc p_func);
|
||||||
static int get_object_count();
|
static int get_object_count();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user