22 #ifndef AGS_ENGINE_AC_DYNOBJ_CC_MANAGED_OBJECT_POOL_H 23 #define AGS_ENGINE_AC_DYNOBJ_CC_MANAGED_OBJECT_POOL_H 25 #include "common/std/vector.h" 26 #include "common/std/queue.h" 27 #include "common/std/map.h" 29 #include "ags/shared/core/platform.h" 30 #include "ags/engine/script/runtime_script_value.h" 31 #include "ags/engine/ac/dynobj/cc_dynamic_object.h" 44 uint operator()(
const char *v)
const {
45 return static_cast<uint
>(
reinterpret_cast<uintptr
>(v));
53 struct ManagedObject {
54 ScriptValueType obj_type;
63 return obj_type != kScValUndefined;
66 ManagedObject() : obj_type(kScValUndefined), handle(0), addr(
nullptr),
67 callback(
nullptr), refCount(0) {
69 ManagedObject(ScriptValueType theType, int32_t theHandle,
71 : obj_type(theType), handle(theHandle), addr(theAddr),
72 callback(theCallback), refCount(0) {
76 int objectCreationCounter;
83 void Init(int32_t theHandle,
const char *theAddress,
ICCDynamicObject *theCallback, ScriptValueType objType);
84 int Remove(ManagedObject &o,
bool force =
false);
86 void RunGarbageCollection();
90 int32_t AddRef(int32_t handle);
91 int CheckDispose(int32_t handle);
92 int32_t SubRef(int32_t handle);
93 int32_t AddressToHandle(
const char *addr);
94 const char *HandleToAddress(int32_t handle);
95 ScriptValueType HandleToAddressAndManager(int32_t handle,
void *&
object,
ICCDynamicObject *&manager);
96 int RemoveObject(
const char *address);
97 void RunGarbageCollectionIfAppropriate();
98 int AddObject(
const char *address,
ICCDynamicObject *callback,
bool plugin_object);
99 int AddUnserializedObject(
const char *address,
ICCDynamicObject *callback,
bool plugin_object,
int handle);
105 const char *disableDisposeForObject{
nullptr };
109 #if DEBUG_MANAGED_OBJECTS 110 #define ManagedObjectLog(...) Debug::Printf(kDbgGroup_ManObj, kDbgMsg_Debug, __VA_ARGS__) 112 #define ManagedObjectLog(...) Definition: achievements_tables.h:27
Definition: cc_dynamic_object.h:97
Definition: managed_object_pool.h:50
Definition: managed_object_pool.h:43
Definition: cc_dynamic_object.h:51