Difference between revisions of "Uno/Cpp/Spec/FreeReference"
From Apache OpenOffice Wiki
m (Fixed section indentation.) |
(Added example snippet.) |
||
Line 31: | Line 31: | ||
bool operator != (FreeReference const & rOther) const | bool operator != (FreeReference const & rOther) const | ||
</code> | </code> | ||
+ | |||
+ | ==Usage Example== | ||
+ | {{:Uno/Cpp/Snippet/FreeReference}} | ||
==Dependencies== | ==Dependencies== |
Revision as of 11:27, 28 September 2006
Type: specification State: draft
Contents
Feature
A free reference, ensuring that the owning environment has always been entered when calling an object.
API
[cpp]
cppu/FreeReference.hxx
template<class T> FreeReference FreeReference() {} FreeReference(cssuno::Reference<T> const & xRef) FreeReference(EnvAwareReference<T> const & rOther)
cssuno::Reference<T> get() const throw (cssuno::RuntimeException)
operator cssuno::Reference<T> () const throw (cssuno::RuntimeException)
T * operator -> () const throw (cssuno::RuntimeException)
bool is() const throw (cssuno::RuntimeException)
void clear()
FreeReference<T> & operator = (FreeReference<T> const & rOther)
void set(cssuno::Reference<T> const & xRef)
bool operator == (FreeReference const & rOther) const
bool operator != (FreeReference const & rOther) const
Usage Example
#include <cppu/EnvGuards.hxx> ... { com::sun::star::uno::Reference<XFoo> ref(...) ... cppu::FreeReference<XFoo> free_xFoo(xFoo); cppu::EnvGuard otherEnv(cppu::Environment("just another env")); free_xFoo->doSomething(); // the free reference ensures that the correct environment etc. gets activated before invokation ... }