Difference between revisions of "Documentation/DevGuide/ProUNO/C++/Mapping of Singletons"
From Apache OpenOffice Wiki
		< Documentation | DevGuide
		
		
m (1 revision(s))  | 
				OOoWikiBot (talk | contribs)  m (Robot: Changing Category:Professional UNO)  | 
				||
| Line 28: | Line 28: | ||
{{PDL1}}  | {{PDL1}}  | ||
| − | [[Category: Professional UNO]]  | + | |
| + | [[Category:Documentation/Developers Guide/Professional UNO]]  | ||
Revision as of 15:07, 8 May 2008
A new-style singleton of the form
singleton Name: XIfc;
is mapped to a C++ class with the same name. The class has a single member function
 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) { ... }
The semantics of such a singleton getter function in C++ are as follows (they are the same as for Java):
- The com.sun.star.uno.XComponentContext argument must be non-null.
 - The singleton getter uses com.sun.star.uno.XComponentContext:getValueByName to obtain the singleton instance (within the "
/singletons/" name space). - If no singleton instance could be obtained, the singleton getter fails by throwing a com.sun.star.uno.DeploymentException. The net effect is that a singleton getter either returns the requested non-null singleton instance, or throws an exception; a singleton getter will never return a null instance.
 
Old-style services are not mapped into the C++ language binding.
| Content on this page is licensed under the Public Documentation License (PDL). |