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_util_XCloseable_idl__
20#define __com_sun_star_util_XCloseable_idl__
21
22#include <com/sun/star/uno/XInterface.idl>
23#include <com/sun/star/util/XCloseBroadcaster.idl>
24
25
26module com {  module sun {  module star {  module util {
27
28/** makes it possible to release any objects in an ordered manner by using
29    a two-step mechanism
30
31    <p>
32    If an object should be terminated, it can be:<br>
33    <ul>
34        <li>disposed (if it supports com::sun::star::lang::XComponent::dispose())</li>
35        <li>closed   (if it supports XCloseable::close())</li>
36    </ul>
37    First version gives the object no chance to disagree with that (e.g. if a
38    process is still running and can't be canceled really). Last version
39    provides this possibility, but can't guarantee real termination of called object.
40    It depends from the environment of an object, if one or both mechanism are necessary.
41    </p>
42
43    <p>
44    Base interface XCloseBroadcaster makes it possible that any listener
45    which is interested on life time of listened object ...
46    <ul>
47        <li>can get a notification about closing of it</li>
48        <li>or can have a veto to break that.</li>
49    </ul>
50    </p>
51
52    @see com::sun::star::lang::XComponent::dispose()
53    @see XCloseBroadcaster
54    @see XCloseListener
55 */
56published interface XCloseable: XCloseBroadcaster
57{
58    /** try to close the object
59
60        <p>
61        Must definitely be called before com::sun::star::lang::XComponent::dispose().
62        But nobody can guarantee real closing of called object - because it can disagree with that if any
63        still running processes can't be canceled yet. It's not allowed to block this call till internal
64        operations will be finished here. They must be canceled or call must return immediately by throwing
65        the CloseVetoException.  Otherwise (if nothing exist to disagree) it must return normally.
66        </p>
67
68        <p>
69        Before any internal processes will be canceled, all registered XCloseListener
70        must be notified. Any of them can disagree with a CloseVetoException too.
71        It's forbidden to catch this exception inside the called close() method because the caller must
72        get this information!
73        </p>
74
75        <p>
76        If somewhere disagree with a CloseVetoException it will not clear who has to close the object again
77        after still running processes was finished. The parameter <var>DeliverOwnership</var> regulate that.
78        If it is set to `FALSE` the caller of the method close() will be the owner of this object in every case.
79        Then it's not allowed to call close() from any other place (may a registered XCloseListener).
80        If it is set to `TRUE` the caller gives up his ownership. If a XCloseListener throw the veto exception
81        he will be the new owner of the closing object. This information is passed to the listener by a parameter of
82        his notification method XCloseListener::queryClosing(). After his operations was finished
83        he MUST try to close it again. If the closing object itself disagree by an exception and the parameter
84        <var>DeliverOwnership</var> was set to `TRUE` the object will be his own owner with all consequences of that.
85        <br><strong>Note:</strong><br>
86        There is no way to get the ownership back if it was delivered!
87        </p>
88
89        <p>
90        If this method was already called on an object it should return without any reaction. Normally it's possible to throw
91        a com::sun::star::lang::DisposedException for already disposed or closed objects
92        (which represent a com::sun::star::uno::RuntimeException and can be thrown by every interface call),
93        but it shouldn't be used here. The veto exception should be the only way to indicates the result.
94        </p>
95
96        @param DeliverOwnership
97                `TRUE` delegates the ownership of this closing object to anyone which throw the CloseVetoException.
98                This new owner has to close the closing object again if his still running processes will be finished.
99                <br>
100                `FALSE` let the ownership at the original one which called the close() method. He must react for possible
101                CloseVetoExceptions and try it again at a later time. This can be useful for a generic UI handling.
102
103        @throws CloseVetoException
104            indicates that the closing object himself or any of his currently registered listener disagree with this close() request.
105
106        @see XCloseListener
107        @see CloseVetoException
108        @see com::sun::star::lang::XComponent::dispose()
109        @see com::sun::star::lang::DisposedException
110     */
111    void close( [in] boolean DeliverOwnership )
112            raises( CloseVetoException );
113};
114
115
116}; }; }; };
117
118#endif
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
121