| AngelScript |

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
weakref object

Path: /sdk/add_on/weakref/

The `weakref` type is a template type for holding weak references to objects, i.e. the references that will not keep the referred object alive.

The type is registered with `RegisterScriptWeakRef(asIScriptEngine*)`.

See Also
  Weak references

# Public C++ interface

class CScriptWeakRef
{
public:
// Constructors
CScriptWeakRef(asITypeInfo *type);
CScriptWeakRef(const CScriptWeakRef &other);
CScriptWeakRef(void *ref, asITypeInfo *type);
~CScriptWeakRef();
// Copy the stored value from another weakref object
CScriptWeakRef &operator=(const CScriptWeakRef &other);
// Compare equalness
bool operator==(const CScriptWeakRef &o) const;
bool operator!=(const CScriptWeakRef &o) const;
// Sets a new reference
CScriptWeakRef &Set(void *newRef);
// Returns the object if it is still alive
// This will increment the refCount of the returned object
void *Get() const;
// Returns true if the contained reference is the same
bool Equals(void *ref) const;
// Returns the type of the reference held
asITypeInfo *GetRefType() const;
};

# Public script interface

See Also
  weakref in the script language