bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / cppuhelper / weakagg.hxx
blobaca4c4b0c210037cd39b47c1154d9d152e414157
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CPPUHELPER_WEAKAGG_HXX
20 #define INCLUDED_CPPUHELPER_WEAKAGG_HXX
22 #include "cppuhelper/weak.hxx"
23 #include "cppuhelper/weakref.hxx"
24 #include "com/sun/star/uno/XAggregation.hpp"
25 #include "cppuhelper/cppuhelperdllapi.h"
28 namespace cppu
31 /** Base class to implement a UNO object supporting weak references, i.e. the object can be held
32 weakly (by a css::uno::WeakReference) and aggregation, i.e. the object can be
33 aggregated by another (delegator).
34 This implementation copes with reference counting. Upon last release(), the virtual dtor
35 is called.
37 @derive
38 Inherit from this class and delegate acquire()/ release() calls. Re-implement
39 XAggregation::queryInterface().
41 class CPPUHELPER_DLLPUBLIC OWeakAggObject
42 : public ::cppu::OWeakObject
43 , public css::uno::XAggregation
45 public:
46 /** Constructor. No delegator set.
48 OWeakAggObject()
51 /** If a delegator is set, then the delegators gets acquired. Otherwise call is delegated to
52 base class ::cppu::OWeakObject.
54 virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
55 /** If a delegator is set, then the delegators gets released. Otherwise call is delegated to
56 base class ::cppu::OWeakObject.
58 virtual void SAL_CALL release() throw() SAL_OVERRIDE;
59 /** If a delegator is set, then the delegator is queried for the demanded interface. If the
60 delegator cannot provide the demanded interface, it calls queryAggregation() on its
61 aggregated objects.
63 @param rType demanded interface type
64 @return demanded type or empty any
65 @see queryAggregation.
67 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
69 /** Set the delegator. The delegator member reference is a weak reference.
71 @param Delegator the object that delegate its queryInterface to this aggregate.
73 virtual void SAL_CALL setDelegator( const css::uno::Reference< css::uno::XInterface > & Delegator ) SAL_OVERRIDE;
74 /** Called by the delegator or queryInterface. Re-implement this method instead of
75 queryInterface.
77 @see queryInterface
79 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) SAL_OVERRIDE;
81 protected:
82 /** Virtual dtor. Called when reference count is 0.
84 @attention
85 Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any
86 exception upon destruction!
88 virtual ~OWeakAggObject() SAL_OVERRIDE;
90 /** weak reference to delegator.
92 css::uno::WeakReferenceHelper xDelegator;
93 private:
94 OWeakAggObject( const OWeakAggObject & rObj ) SAL_DELETED_FUNCTION;
95 OWeakAggObject & operator = ( const OWeakAggObject & rObj )
96 SAL_DELETED_FUNCTION;
101 #endif
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */