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

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

Revision as of 17:35, 23 February 2008

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