Singleton 的映射

From Apache OpenOffice Wiki
Jump to: navigation, search



以下形式的新式 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 中的语义相同):

  • 如果未获取 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).
Personal tools
In other languages