Difference between revisions of "Uno/Cpp/Snippet/Dereference a WeakReference"

From Apache OpenOffice Wiki
< Uno‎ | Cpp
Jump to: navigation, search
m
m
 
Line 1: Line 1:
<source lang="cpp">
+
<syntaxhighlight lang="cpp">
 
class A
 
class A
 
{
 
{
Line 19: Line 19:
 
   }
 
   }
 
};
 
};
</source>
+
</syntaxhighlight>
 
<noinclude>[[Category:Snippet]][[Category:Uno]][[Category:Cpp]][[Category:Uno:Cpp:Snippet]]</noinclude>
 
<noinclude>[[Category:Snippet]][[Category:Uno]][[Category:Cpp]][[Category:Uno:Cpp:Snippet]]</noinclude>

Latest revision as of 10:00, 19 May 2021

class A
{
private:
   WeakReference< XInputStream > m_wrStream;
   void set( const Reference< XInputStream > &r )
   {
      // store to weak reference
      m_wrStream = r;
   }
   Reference< XInputStream > get()
   {
       // try to make the weak reference hard
       Reference< XIntputStream > r = m_wrStream;
 
       // Note : r.is() may be true or not, depending on whether
       //        the object has been destroyed before.
       return r;
   }
};
Personal tools