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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
20 #define _COM_SUN_STAR_UNO_REFERENCE_H_
21 
22 #include <rtl/alloc.h>
23 
24 
25 namespace com
26 {
27 namespace sun
28 {
29 namespace star
30 {
31 namespace uno
32 {
33 
34 class RuntimeException;
35 class XInterface;
36 class Type;
37 class Any;
38 
44 {
49 };
50 
55 {
56 protected:
59  XInterface * _pInterface;
60 
67  inline static XInterface * SAL_CALL iquery( XInterface * pInterface, const Type & rType )
68  SAL_THROW( (RuntimeException) );
69 #ifndef EXCEPTIONS_OFF
70 
77  inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface, const Type & rType )
78  SAL_THROW( (RuntimeException) );
79 #endif
80 
81 public:
86  inline XInterface * SAL_CALL get() const SAL_THROW(())
87  { return _pInterface; }
88 
93  inline sal_Bool SAL_CALL is() const SAL_THROW(())
94  { return (0 != _pInterface); }
95 
102  inline sal_Bool SAL_CALL operator == ( XInterface * pInterface ) const SAL_THROW(());
109  inline sal_Bool SAL_CALL operator != ( XInterface * pInterface ) const SAL_THROW(());
110 
117  inline sal_Bool SAL_CALL operator == ( const BaseReference & rRef ) const SAL_THROW(());
124  inline sal_Bool SAL_CALL operator != ( const BaseReference & rRef ) const SAL_THROW(());
125 
131  inline sal_Bool SAL_CALL operator < ( const BaseReference & rRef ) const SAL_THROW(());
132 };
133 
137 {
141 };
142 #ifndef EXCEPTIONS_OFF
143 
147 {
151 };
158 {
160 };
161 #endif
162 
167 template< class interface_type >
168 class Reference : public BaseReference
169 {
175  inline static XInterface * SAL_CALL iquery( XInterface * pInterface )
176  SAL_THROW( (RuntimeException) );
177 #ifndef EXCEPTIONS_OFF
178 
184  inline static XInterface * SAL_CALL iquery_throw( XInterface * pInterface )
185  SAL_THROW( (RuntimeException) );
191  inline static interface_type * SAL_CALL iset_throw( interface_type * pInterface )
192  SAL_THROW( (RuntimeException) );
193 #endif
194 
206  static inline interface_type * castFromXInterface(XInterface * p) {
207  return static_cast< interface_type * >(static_cast< void * >(p));
208  }
209 
221  static inline XInterface * castToXInterface(interface_type * p) {
222  return static_cast< XInterface * >(static_cast< void * >(p));
223  }
224 
225 public:
227  // these are here to force memory de/allocation to sal lib.
228  inline static void * SAL_CALL operator new ( ::size_t nSize ) SAL_THROW(())
229  { return ::rtl_allocateMemory( nSize ); }
230  inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
231  { ::rtl_freeMemory( pMem ); }
232  inline static void * SAL_CALL operator new ( ::size_t, void * pMem ) SAL_THROW(())
233  { return pMem; }
234  inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
235  {}
237 
240  inline ~Reference() SAL_THROW(());
241 
244  inline Reference() SAL_THROW(());
245 
250  inline Reference( const Reference< interface_type > & rRef ) SAL_THROW(());
255  inline Reference( interface_type * pInterface ) SAL_THROW(());
256 
262  inline Reference( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(());
270  inline Reference( interface_type * pInterface, UnoReference_NoAcquire dummy ) SAL_THROW(());
271 
277  inline Reference( const BaseReference & rRef, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) );
283  inline Reference( XInterface * pInterface, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
289  inline Reference( const Any & rAny, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
290 #ifndef EXCEPTIONS_OFF
291 
298  inline Reference( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
306  inline Reference( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
314  inline Reference( const Any & rAny, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
323  inline Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) );
332  inline Reference( interface_type * pInterface, UnoReference_SetThrow dummy ) SAL_THROW( (RuntimeException) );
333 #endif
334 
339  inline SAL_CALL operator const Reference< XInterface > & () const SAL_THROW(())
340  { return * reinterpret_cast< const Reference< XInterface > * >( this ); }
341 
346  inline interface_type * SAL_CALL operator -> () const SAL_THROW(())
347  { return castFromXInterface(_pInterface); }
348 
353  inline interface_type * SAL_CALL get() const SAL_THROW(())
354  { return castFromXInterface(_pInterface); }
355 
358  inline void SAL_CALL clear() SAL_THROW(());
359 
365  inline sal_Bool SAL_CALL set( const Reference< interface_type > & rRef ) SAL_THROW(());
371  inline sal_Bool SAL_CALL set( interface_type * pInterface ) SAL_THROW(());
372 
379  inline sal_Bool SAL_CALL set( interface_type * pInterface, __sal_NoAcquire dummy) SAL_THROW(());
388  inline sal_Bool SAL_CALL set( interface_type * pInterface, UnoReference_NoAcquire dummy) SAL_THROW(());
389 
397  inline sal_Bool SAL_CALL set( XInterface * pInterface, UnoReference_Query dummy ) SAL_THROW( (RuntimeException) );
405  inline sal_Bool SAL_CALL set( const BaseReference & rRef, UnoReference_Query dummy) SAL_THROW( (RuntimeException) );
406 
418  inline bool set( Any const & rAny, UnoReference_Query dummy );
419 
420 #ifndef EXCEPTIONS_OFF
421 
429  inline void SAL_CALL set( XInterface * pInterface, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
438  inline void SAL_CALL set( const BaseReference & rRef, UnoReference_QueryThrow dummy ) SAL_THROW( (RuntimeException) );
439 
449  inline void set( Any const & rAny, UnoReference_QueryThrow dummy);
459  inline void SAL_CALL set( interface_type * pInterface, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) );
469  inline void SAL_CALL set( const Reference< interface_type > & rRef, UnoReference_SetThrow dummy) SAL_THROW( (RuntimeException) );
470 
471 #endif
472 
479  inline Reference< interface_type > & SAL_CALL operator = ( interface_type * pInterface ) SAL_THROW(());
487 
493  inline static Reference< interface_type > SAL_CALL query( const BaseReference & rRef ) SAL_THROW( (RuntimeException) );
499  inline static Reference< interface_type > SAL_CALL query( XInterface * pInterface ) SAL_THROW( (RuntimeException) );
500 };
501 
503 
505 template <typename T>
506 inline T * get_pointer( Reference<T> const& r )
507 {
508  return r.get();
509 }
511 
512 }
513 }
514 }
515 }
516 
517 #endif
518 
519 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */