/** * @author Alberto DEMICHELIS * @author Edouard DUPIN * @copyright 2018, Edouard DUPIN, all right reserved * @copyright 2003-2017, Alberto DEMICHELIS, all right reserved * @license MPL-2 (see license file) */ #include #include #include #include #include rabbit::WeakRef * rabbit::RefCounted::getWeakRef(rabbit::ObjectType type) { if(!_weakref) { sq_new(_weakref, WeakRef); _weakref->_obj._unVal.raw = 0; //clean the whole union _weakref->_obj._type = type; _weakref->_obj._unVal.pRefCounted = this; } return _weakref; } rabbit::RefCounted::~RefCounted() { if(_weakref) { _weakref->_obj._type = rabbit::OT_NULL; _weakref->_obj._unVal.pRefCounted = NULL; } } void rabbit::RefCounted::refCountIncrement() { _uiRef++; } int64_t rabbit::RefCounted::refCountDecrement() { return --_uiRef; } int64_t rabbit::RefCounted::refCountget() { return _uiRef; }