Difference between revisions of "Uno/Cpp/Spec/FreeReference"

From Apache OpenOffice Wiki
< Uno‎ | Cpp‎ | Spec
Jump to: navigation, search
m (API: Fixed <code> tag ...)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
author[[User:Kr|Kr]] <br>
+
Type: Specification State: Evolving Availability: URE 1.3 (SRC680_m212)
version: {{REVISIONID}} <br>
+
state:  draft          <br>
+
created: 01/10/2006    <br>
+
type:    specification <br>
+
type:   specification
+
  
== C++ UNO ==
+
==Feature==
=== Environment Aware Reference ===
+
A free reference, ensuring that the managing environment has always been entered when calling an object.
  
; Feature
+
==API==
: An environment aware reference. Ensuring that the owning environment has always been entered when calling an object.
+
<source lang="cpp">
 +
cppu/FreeReference.hxx
  
; Rationale :
+
  template<class T> FreeReference
 +
    FreeReference() {}
 +
    FreeReference(cssuno::Reference<T> const & xRef)
 +
    FreeReference(EnvAwareReference<T> const & rOther)
  
; API
+
    cssuno::Reference<T> get() const throw (cssuno::RuntimeException)
: <code>template<class T> EnvAwareReference</code>
+
: <code>EnvAwareReference() {}</code>
+
: <code>EnvAwareReference(cssuno::Reference<T> const & xRef)</code>
+
: <code>EnvAwareReference(EnvAwareReference<T> const & rOther)</code>
+
: <code>cssuno::Reference<T> get() const throw (cssuno::RuntimeException)</code>
+
: <code>operator cssuno::Reference<T> () const throw (cssuno::RuntimeException)</code>
+
: <code>T * operator -> () const throw (cssuno::RuntimeException)</code>
+
: <code>bool is() const throw (cssuno::RuntimeException)</code>
+
: <code>void clear()</code>
+
: <code>EnvAwareReference<T> & operator = (EnvAwareReference<T> const & rOther)</code>
+
: <code>void set(cssuno::Reference<T> const & xRef)</code>
+
: <code>bool operator == (EnvAwareReference const & rOther) const</code>
+
: <code>bool operator != (EnvAwareReference const & rOther) const</code>
+
   
+
; Compatibility Issues: None.
+
  
; Dependencies:
+
    operator cssuno::Reference<T> () const throw (cssuno::RuntimeException)
:* C++ uno::Environment
+
 
:* Stacked Environments
+
    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
 +
</source>
 +
 
 +
==Usage Example==
 +
{{:Uno/Cpp/Snippet/FreeReference}}
 +
 
 +
More Examples:
 +
* [[Uno/Cpp/Snippet/Function always returning an appropriate object]]
 +
 
 +
==Dependencies==
 +
* [[Uno/Cpp/Spec/Environment]]
 +
* [[Uno/Cpp/Spec/Environment Stack]]
 +
 
 +
 
 +
[[Category:Evolving]]
 +
[[Category:Spec]]
 +
[[Category:Uno]]
 +
[[Category:Uno:Cpp]]

Latest revision as of 12:32, 12 March 2009

Type: Specification State: Evolving Availability: URE 1.3 (SRC680_m212)

Feature

A free reference, ensuring that the managing environment has always been entered when calling an object.

API

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
  ...
}

More Examples:

Dependencies

Personal tools