Difference between revisions of "Uno/Cpp/Snippet/Dereference a WeakReference"
From Apache OpenOffice Wiki
m (Extract from Cpp Uno introduction) |
SergeMoutou (Talk | contribs) m |
||
Line 1: | Line 1: | ||
− | < | + | <source lang="cpp"> |
class A | class A | ||
{ | { | ||
Line 19: | Line 19: | ||
} | } | ||
}; | }; | ||
− | </ | + | </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; } };