AngelScript
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
asITypeInfo
The interface for describing types This interface is used to describe the types in the script engine.
Definition: angelscript.h:3527