/** T must be a class that extends SvRefBase */ template<typename T> class SAL_DLLPUBLIC_RTTI SvRef final { public:
constexpr SvRef(): pObj(nullptr) {}
/** Classes that want to be referenced-counted via SvRef<T>, should extend this base class */ class TOOLS_DLLPUBLIC SvRefBase
{ // work around a clang 3.5 optimization bug: if the bNoDelete is *first* // it mis-compiles "if (--nRefCount == 0)" and never deletes any object unsignedint nRefCount : 31; // the only reason this is not bool is because MSVC cannot handle mixed type bitfields unsignedint bNoDelete : 1;
void AddNextRef()
{
assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" );
++nRefCount;
}
void AddFirstRef()
{
assert( nRefCount < (1 << 30) && "Do not add refs to dead objects" ); if( bNoDelete )
bNoDelete = 0;
++nRefCount;
}
void ReleaseRef()
{
assert( nRefCount >= 1); if( --nRefCount == 0 && !bNoDelete)
{ // I'm not sure about the original purpose of this line, but right now // it serves the purpose that anything that attempts to do an AddRef() // after an object is deleted will trip an assert.
nRefCount = 1 << 30; deletethis;
}
}
/** SvCompatWeakHdl acts as an intermediary between SvCompatWeakRef<T> and T.
*/ template<typename T> class SvCompatWeakHdl final : public SvRefBase
{ friendclass SvCompatWeakBase<T>;
T* _pObj;
/** We only have one place that extends this, in include/sfx2/frame.hxx, class SfxFrame. ItsfunctionistonotifytheSvCompatWeakHdlwhenanSfxFrameobjectisdeleted.
*/ template<typename T> class SvCompatWeakBase
{
tools::SvRef< SvCompatWeakHdl<T> > _xHdl;
public: /** Does not use initializer due to compiler warnings, becausethelifetimeofthe_xHdlobjectcanexceedthelifetimeofthisclass.
*/
SvCompatWeakBase( T* pObj ) { _xHdl = new SvCompatWeakHdl<T>( pObj ); }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.