Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/inc/helper/simplereferencecomponent.hxx
Line
Count
Source
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
20
#pragma once
21
22
#include <osl/interlck.h>
23
24
namespace sd
25
{
26
/** A simple base implementation for reference-counted components.
27
    acts like sal::SimpleReferenceObject but calls the virtual disposing()
28
    methods before the ref count switches from 1 to zero.
29
 */
30
class SimpleReferenceComponent
31
{
32
public:
33
    SimpleReferenceComponent();
34
35
    /** @ATTENTION
36
        The results are undefined if, for any individual instance of
37
        SimpleReferenceComponent, the total number of calls to acquire() exceeds
38
        the total number of calls to release() by a platform dependent amount
39
        (which, hopefully, is quite large).
40
     */
41
    void acquire();
42
    void release();
43
44
    void Dispose();
45
46
0
    bool isDisposed() const { return mbDisposed; }
47
48
protected:
49
    virtual void disposing();
50
51
    virtual ~SimpleReferenceComponent();
52
53
private:
54
    oslInterlockedCount m_nCount;
55
56
    SimpleReferenceComponent(SimpleReferenceComponent const&) = delete;
57
    void operator=(SimpleReferenceComponent const&) = delete;
58
59
    bool mbDisposed;
60
};
61
}
62
63
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */