My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Reference.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
29 #define _COM_SUN_STAR_UNO_REFERENCE_H_
30 
31 #include <rtl/alloc.h>
32 
33 
34 namespace com
35 {
36 namespace sun
37 {
38 namespace star
39 {
40 namespace uno
41 {
42 
43 class RuntimeException;
44 class XInterface;
45 class Type;
46 class Any;
47 
53 {
58 };
59 
64 {
65 protected:
68  XInterface * _pInterface;
69 
76  inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType )
77  SAL_THROW( (RuntimeException) );
78 #ifndef EXCEPTIONS_OFF
79 
86  inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType )
87  SAL_THROW( (RuntimeException) );
88 #endif
89 
90 public:
95  inline XInterface * SAL_CALL get() const SAL_THROW(())
96  { return _pInterface; }
97 
102  inline sal_Bool SAL_CALL is() const SAL_THROW(())
103  { return (0 != _pInterface); }
104 
111  inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW(());
118  inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW(());
119 
126  inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW(());
133  inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW(());
134 
140  inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW(());
141 };
142 
146 {
150 };
151 #ifndef EXCEPTIONS_OFF
152 
156 {
160 };
167 {
169 };
170 #endif
171 
176 template< class interface_type >
177 class Reference : public BaseReference
178 {
184  inline static XInterface * SAL_CALL iquery( XInterface * pInterface )
185  SAL_THROW( (RuntimeException) );
186 #ifndef EXCEPTIONS_OFF
187 
193  inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface )
194  SAL_THROW( (RuntimeException) );
200  inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface )
201  SAL_THROW( (RuntimeException) );
202 #endif
203 
215  static inline interface_type * castFromXInterface(XInterface * p) {
216  return static_cast< interface_type * >(static_cast< void * >(p));
217  }
218 
230  static inline XInterface * castToXInterface(interface_type * p) {
231  return static_cast< XInterface * >(static_cast< void * >(p));
232  }
233 
234 public:
236  // these are here to force memory de/allocation to sal lib.
237  inline static void * SAL_CALL operator new ( ::size_t nSize ) SAL_THROW(())
238  { return ::rtl_allocateMemory( nSize ); }
239  inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
240  { ::rtl_freeMemory( pMem ); }
241  inline static void * SAL_CALL operator new ( ::size_t, void * pMem ) SAL_THROW(())
242  { return pMem; }
243  inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
244  {}
246 
249  inline ~Reference() SAL_THROW(());
250 
253  inline Reference() SAL_THROW(());
254 
259  inline Reference( const Reference< interface_type > & rRef ) SAL_THROW(());
264  inline Reference( interface_type * pInterface ) SAL_THROW(());
265 
271  inline Reference( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(());
279  inline Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ) SAL_THROW(());
280 
286  inline Reference( const BaseReference & rRef, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) );
292  inline Reference( XInterface * pInterface, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
298  inline Reference( const Any & rAny, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
299 #ifndef EXCEPTIONS_OFF
300 
307  inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
315  inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
323  inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
332  inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) );
341  inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) );
342 #endif
343 
348  inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW(())
349  { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
350 
355  inline interface_type * SAL_CALL operator -> () const SAL_THROW(())
356  { return castFromXInterface(_pInterface); }
357 
362  inline interface_type * SAL_CALL get() const SAL_THROW(())
363  { return castFromXInterface(_pInterface); }
364 
367  inline void SAL_CALL clear() SAL_THROW(());
368 
374  inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW(());
380  inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW(());
381 
388  inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(());
397  inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy) SAL_THROW(());
398 
406  inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) );
414  inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
415 
427  inline bool set( Any const & rAny, UnoReference_Query dummy );
428 
429 #ifndef EXCEPTIONS_OFF
430 
438  inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
447  inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
448 
458  inline void set( Any const & rAny, UnoReference_QueryThrow dummy);
468  inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) );
478  inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) );
479 
480 #endif
481 
488  inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW(());
496 
502  inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) );
508  inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) );
509 };
510 
512 
514 template <typename T>
515 inline T * get_pointer( Reference<T> const& r )
516 {
517  return r.get();
518 }
520 
521 }
522 }
523 }
524 }
525 
526 #endif
527 
528 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */