make ValueTransfer easier to understand
[LibreOffice.git] / include / cppuhelper / weakagg.hxx
blob0b770a42842be76fff365f5e0a3745d21a3df3fc
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 .
21 * This file is part of LibreOffice published API.
23 #ifndef INCLUDED_CPPUHELPER_WEAKAGG_HXX
24 #define INCLUDED_CPPUHELPER_WEAKAGG_HXX
26 #include "cppuhelper/weak.hxx"
27 #include "cppuhelper/weakref.hxx"
28 #include "com/sun/star/uno/XAggregation.hpp"
29 #include "cppuhelper/cppuhelperdllapi.h"
32 namespace cppu
35 /** Base class to implement a UNO object supporting weak references, i.e. the object can be held
36 weakly (by a css::uno::WeakReference) and aggregation, i.e. the object can be
37 aggregated by another (delegator).
38 This implementation copes with reference counting. Upon last release(), the virtual dtor
39 is called.
41 @derive
42 Inherit from this class and delegate acquire()/ release() calls. Re-implement
43 XAggregation::queryInterface().
45 class CPPUHELPER_DLLPUBLIC OWeakAggObject
46 : public ::cppu::OWeakObject
47 , public css::uno::XAggregation
49 public:
50 /** Constructor. No delegator set.
52 OWeakAggObject()
55 /** If a delegator is set, then the delegators gets acquired. Otherwise call is delegated to
56 base class ::cppu::OWeakObject.
58 virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE;
59 /** If a delegator is set, then the delegators gets released. Otherwise call is delegated to
60 base class ::cppu::OWeakObject.
62 virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE;
63 /** If a delegator is set, then the delegator is queried for the demanded interface. If the
64 delegator cannot provide the demanded interface, it calls queryAggregation() on its
65 aggregated objects.
67 @param rType demanded interface type
68 @return demanded type or empty any
69 @see queryAggregation.
71 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
73 /** Set the delegator. The delegator member reference is a weak reference.
75 @param Delegator the object that delegate its queryInterface to this aggregate.
77 virtual void SAL_CALL setDelegator( const css::uno::Reference< css::uno::XInterface > & Delegator ) SAL_OVERRIDE;
78 /** Called by the delegator or queryInterface. Re-implement this method instead of
79 queryInterface.
81 @see queryInterface
83 virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & rType ) SAL_OVERRIDE;
85 protected:
86 /** Virtual dtor. Called when reference count is 0.
88 @attention
89 Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any
90 exception upon destruction!
92 virtual ~OWeakAggObject() SAL_OVERRIDE;
94 /** weak reference to delegator.
96 css::uno::WeakReferenceHelper xDelegator;
97 private:
98 OWeakAggObject( const OWeakAggObject & rObj ) SAL_DELETED_FUNCTION;
99 OWeakAggObject & operator = ( const OWeakAggObject & rObj )
100 SAL_DELETED_FUNCTION;
105 #endif
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */