33 #include "safe_refcount.h" 35 #include "object_type_db.h" 48 static void _bind_methods();
52 _FORCE_INLINE_
bool is_referenced()
const {
return refcount_init.get()<1; }
56 int reference_get_count()
const;
68 Reference * get_reference_from_ref(
const RefBase &p_base);
69 virtual Reference * get_reference()
const=0;
70 char * get_refptr_data(
const RefPtr &p_refptr)
const;
82 void ref(
const Ref& p_from ) {
84 if (p_from.reference==reference)
89 reference=p_from.reference;
91 reference->reference();
94 void ref_pointer( T* p_ref ) {
96 ERR_FAIL_COND(!p_ref);
98 if (p_ref->init_ref())
106 _FORCE_INLINE_
bool operator<(const Ref<T>& p_r)
const {
108 return reference<p_r.reference;
110 _FORCE_INLINE_
bool operator==(
const Ref<T>& p_r)
const {
112 return reference==p_r.reference;
114 _FORCE_INLINE_
bool operator!=(
const Ref<T>& p_r)
const {
116 return reference!=p_r.reference;
119 _FORCE_INLINE_ T* operator->() {
124 _FORCE_INLINE_ T* operator*() {
129 _FORCE_INLINE_
const T* operator->()
const {
134 _FORCE_INLINE_
const T* ptr()
const {
138 _FORCE_INLINE_ T* ptr() {
143 _FORCE_INLINE_
const T* operator*()
const {
148 RefPtr get_ref_ptr()
const {
160 return get_ref_ptr();
167 return Variant( get_ref_ptr() );
171 void operator=(
const Ref& p_from ) {
176 template<
class T_Other>
185 r.reference=refb->cast_to<T>();
190 void operator=(
const RefPtr& p_refptr ) {
199 r.reference=refb->cast_to<T>();
205 void operator=(
const Variant& p_variant ) {
215 r.reference=refb->cast_to<T>();
220 Ref(
const Ref& p_from ) {
226 template<
class T_Other>
236 r.reference=refb->cast_to<T>();
241 Ref( T* p_reference ) {
244 ref_pointer(p_reference);
260 r.reference=refb->cast_to<T>();
277 r.reference=refb->cast_to<T>();
282 inline bool is_valid()
const {
return reference!=NULL; }
283 inline bool is_null()
const {
return reference==NULL; }
290 if (reference && reference->unreference()) {
292 memdelete(reference);
322 static void _bind_methods();
326 void set_obj(
Object *p_object);
327 void set_ref(
const REF& p_ref);
334 #endif // REFERENCE_H
Definition: reference.h:78
Definition: safe_refcount.h:336
Definition: reference.h:40
Definition: reference.h:316