Difference between revisions of "Zh/Documentation/DevGuide/ProUNO/Object Identity"
From Apache OpenOffice Wiki
< Zh | Documentation
m (New page: {{Documentation/DevGuide/ProUNOTOC/Zh |ProUNO2b=block |ShowPrevNext=block |PrevPage=zh/Documentation/DevGuide/ProUNO/Differences Between the Lifetime of C++ and Java Objects |NextPage=Zh/D...) |
m |
||
Line 5: | Line 5: | ||
|NextPage=Zh/Documentation/DevGuide/ProUNO/UNO Language Bindings | |NextPage=Zh/Documentation/DevGuide/ProUNO/UNO Language Bindings | ||
}} | }} | ||
− | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}} | |
{{DISPLAYTITLE:对象标识}} | {{DISPLAYTITLE:对象标识}} | ||
Latest revision as of 02:34, 14 May 2009
UNO 保证如果两个对象引用相同,将执行一项检查,并且不管返回 true 还是 false,始终产生正确结果。这与 CORBA 不同,后者返回 false 不一定意味着对象是不同的。
每个 UNO 运行时环境定义应该如何执行此检查。在 Java UNO 中,有一个静态 areSame()
函数,它位于 com.sun.star.uno.UnoRuntime
类中。在 C++ 中,通过 Reference<>::operator == ()
函数执行检查,该函数在两个引用中查询 XInterface
并比较获得的 XInterface
指针。
这会对 API 设计产生直接的影响。例如,请看 com.sun.star.lang.XComponent:
interface XComponent: com::sun::star::uno::XInterface { void dispose(); void addEventListener( [in] XEventListener xListener ); void removeEventListener( [in] XEventListener aListener ); };
如果实现检查对象标识,则以侦听器引用为参数的方法 removeEventListener()
是合乎逻辑的,否则就无法标识需要删除的侦听器。CORBA 接口的设计方法与此不同。它们需要一个对象 ID,因为未保证对象标识。
Content on this page is licensed under the Public Documentation License (PDL). |