Difference between revisions of "Documentation/DevGuide/ProUNO/Object Identity"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Professional UNO)
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
|NextPage=Documentation/DevGuide/ProUNO/UNO Language Bindings
 
|NextPage=Documentation/DevGuide/ProUNO/UNO Language Bindings
 
}}
 
}}
 +
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}}
 
{{DISPLAYTITLE:Object Identity}}
 
{{DISPLAYTITLE:Object Identity}}
 
UNO guarantees if two object references are identical, that a check is performed and it always leads to a correct result, whether it be true or false. This is different from CORBA, where a return of false does not necessarily mean that the objects are different.
 
UNO guarantees if two object references are identical, that a check is performed and it always leads to a correct result, whether it be true or false. This is different from CORBA, where a return of false does not necessarily mean that the objects are different.
Line 11: Line 12:
  
 
This has a direct effect in the API design. For instance, look at <idl>com.sun.star.lang.XComponent</idl>:
 
This has a direct effect in the API design. For instance, look at <idl>com.sun.star.lang.XComponent</idl>:
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   interface XComponent: com::sun::star::uno::XInterface
 
   interface XComponent: com::sun::star::uno::XInterface
 
   {  
 
   {  
Line 18: Line 19:
 
       void removeEventListener( [in] XEventListener aListener );  
 
       void removeEventListener( [in] XEventListener aListener );  
 
   };  
 
   };  
</source>
+
</syntaxhighlight>
 
The method <code>removeEventListener()</code> that takes a listener reference, is logical if the implementation can check for object identity, otherwise it could not identify the listener that has to be removed. CORBA interfaces are not designed in this manner. They need an object ID, because object identity is not guaranteed.
 
The method <code>removeEventListener()</code> that takes a listener reference, is logical if the implementation can check for object identity, otherwise it could not identify the listener that has to be removed. CORBA interfaces are not designed in this manner. They need an object ID, because object identity is not guaranteed.
  
 
{{PDL1}}
 
{{PDL1}}
  
[[Category:Documentation/Developers Guide/Professional UNO]]
+
[[Category:Documentation/Developer's Guide/Professional UNO]]

Latest revision as of 12:26, 23 December 2020



UNO guarantees if two object references are identical, that a check is performed and it always leads to a correct result, whether it be true or false. This is different from CORBA, where a return of false does not necessarily mean that the objects are different.

Every UNO runtime environment defines how this check should be performed. In Java UNO, there is a static areSame() function at the com.sun.star.uno.UnoRuntime class. In C++, the check is performed with the Reference<>::operator == () function that queries both references for XInterface and compares the resulting XInterface pointers.

This has a direct effect in the API design. For instance, look at com.sun.star.lang.XComponent:

  interface XComponent: com::sun::star::uno::XInterface
  { 
      void dispose(); 
      void addEventListener( [in] XEventListener xListener ); 
      void removeEventListener( [in] XEventListener aListener ); 
  };

The method removeEventListener() that takes a listener reference, is logical if the implementation can check for object identity, otherwise it could not identify the listener that has to be removed. CORBA interfaces are not designed in this manner. They need an object ID, because object identity is not guaranteed.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages