Difference between revisions of "Zh/Documentation/DevGuide/ProUNO/C++/Mapping of Singletons"
From Apache OpenOffice Wiki
< Zh | Documentation
(New page: {{Documentation/DevGuide/ProUNOTOC/Zh |ProUNO2c=block |ProUNO2cC++=block |ProUNO2cC++TM=block |ShowPrevNext=block |PrevPage=Zh/Documentation/DevGuide/ProUNO/C++/Mapping of Services |NextPa...) |
m |
||
Line 7: | Line 7: | ||
|NextPage=Zh/Documentation/DevGuide/ProUNO/C++/Using Weak References | |NextPage=Zh/Documentation/DevGuide/ProUNO/C++/Using Weak References | ||
}} | }} | ||
− | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/C++/{{SUBPAGENAME}}}} | |
{{DISPLAYTITLE:Singleton 的映射}} | {{DISPLAYTITLE:Singleton 的映射}} | ||
Latest revision as of 02:50, 14 May 2009
以下形式的新式 singleton
singleton Name: XIfc;
被映射成同名的 C++ 类。该类具有单一成员函数
public: static com::sun::star::uno::Reference< XIfc > get( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context) throw (com::sun::star::uno::RuntimeException) { ... }
在 C++ 中,这种 singleton getter 函数的语义如下(与 Java 中的语义相同):
- com.sun.star.uno.XComponentContext:getValueByName 在
“/singletons/”
名称空间内获取 singleton 实例。
- 如果未获取 singleton 实例,则 singleton getter 会抛出 com.sun.star.uno.DeploymentException 并以失败告终。实际结果是 singleton getter 或者返回所请求服务的 singleton 非空实例,或者抛出异常;singleton getter 决不会返回空实例。
没有将旧式服务映射至 C++ 语言绑定。
Content on this page is licensed under the Public Documentation License (PDL). |