Difference between revisions of "Documentation/DevGuide/WritingUNO/XWeak"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
|NextPage=Documentation/DevGuide/WritingUNO/XComponent
 
|NextPage=Documentation/DevGuide/WritingUNO/XComponent
 
}}
 
}}
[[zh:Zh/Documentation/DevGuide/WritingUNO/XWeak]]
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/WritingUNO/{{SUBPAGENAME}}}}
 
{{DISPLAYTITLE:XWeak}}
 
{{DISPLAYTITLE:XWeak}}
 
<!--<idltopic>com.sun.star.uno.XWeak</idltopic>-->
 
<!--<idltopic>com.sun.star.uno.XWeak</idltopic>-->
 
A component supporting <code>XWeak</code> offers other objects to hold a reference on itself without preventing it from being destroyed when it is no longer needed. Thus, cyclic references can be avoided easily. The chapter [[Documentation/DevGuide/ProUNO/Lifetime of UNO objects|Lifetime of UNO Objects]] discusses this in detail. In Java, derive from the Java helper <code>class com.sun.star.lib.uno.helper.WeakBase</code> to support <code>XWeak</code>. If a C++ component is derived from one of the <code>::cppu::Weak...ImplHelperNN</code> template classes as proposed in the section [[Documentation/DevGuide/WritingUNO/C++/C++ Component|C++ Component]], a <code>XWeak</code> support is obtained, virtually for free. For the sake of completeness, this is the <code>XWeak</code> specification:
 
A component supporting <code>XWeak</code> offers other objects to hold a reference on itself without preventing it from being destroyed when it is no longer needed. Thus, cyclic references can be avoided easily. The chapter [[Documentation/DevGuide/ProUNO/Lifetime of UNO objects|Lifetime of UNO Objects]] discusses this in detail. In Java, derive from the Java helper <code>class com.sun.star.lib.uno.helper.WeakBase</code> to support <code>XWeak</code>. If a C++ component is derived from one of the <code>::cppu::Weak...ImplHelperNN</code> template classes as proposed in the section [[Documentation/DevGuide/WritingUNO/C++/C++ Component|C++ Component]], a <code>XWeak</code> support is obtained, virtually for free. For the sake of completeness, this is the <code>XWeak</code> specification:
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   // module com::sun::star::uno::XWeak
 
   // module com::sun::star::uno::XWeak
 
    
 
    
Line 16: Line 16:
 
       com::sun::star::uno::XAdapter queryAdapter();  
 
       com::sun::star::uno::XAdapter queryAdapter();  
 
   };
 
   };
</source>
+
</syntaxhighlight>
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Writing UNO Components]]
 
[[Category:Documentation/Developer's Guide/Writing UNO Components]]

Latest revision as of 17:20, 23 December 2020



A component supporting XWeak offers other objects to hold a reference on itself without preventing it from being destroyed when it is no longer needed. Thus, cyclic references can be avoided easily. The chapter Lifetime of UNO Objects discusses this in detail. In Java, derive from the Java helper class com.sun.star.lib.uno.helper.WeakBase to support XWeak. If a C++ component is derived from one of the ::cppu::Weak...ImplHelperNN template classes as proposed in the section C++ Component, a XWeak support is obtained, virtually for free. For the sake of completeness, this is the XWeak specification:

  // module com::sun::star::uno::XWeak
 
  interface XWeak: com::sun::star::uno::XInterface
  { 
      com::sun::star::uno::XAdapter queryAdapter(); 
  };
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages