2023-12-14 21:54:22 +01:00
|
|
|
#ifndef REF_PTR_H
|
|
|
|
#define REF_PTR_H
|
2023-12-17 15:39:29 +01:00
|
|
|
|
2023-12-14 21:54:22 +01:00
|
|
|
/* ref_ptr.h */
|
2023-12-17 15:39:29 +01:00
|
|
|
|
2023-12-14 21:54:22 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
@author Juan Linietsky <reduzio@gmail.com>
|
|
|
|
* This class exists to workaround a limitation in C++ but keep the design OK.
|
|
|
|
* It's basically an opaque container of a Reference reference, so Variant can use it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "core/containers/rid.h"
|
|
|
|
|
|
|
|
class RefPtr {
|
|
|
|
enum {
|
|
|
|
|
|
|
|
DATASIZE = sizeof(void *) //*4 -ref was shrunk
|
|
|
|
};
|
|
|
|
|
|
|
|
mutable char data[DATASIZE]; // too much probably, virtual class + pointer
|
|
|
|
public:
|
|
|
|
bool is_null() const;
|
|
|
|
void operator=(const RefPtr &p_other);
|
|
|
|
bool operator==(const RefPtr &p_other) const;
|
|
|
|
bool operator!=(const RefPtr &p_other) const;
|
|
|
|
RID get_rid() const;
|
|
|
|
void unref();
|
|
|
|
_FORCE_INLINE_ void *get_data() const { return data; }
|
|
|
|
RefPtr(const RefPtr &p_other);
|
|
|
|
RefPtr();
|
|
|
|
~RefPtr();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // REF_PTR_H
|