1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef _SD_SIMPLEREFERENCECOMPONENT_HXX_
21 #define _SD_SIMPLEREFERENCECOMPONENT_HXX_
23 #include "osl/interlck.h"
24 #include "sal/types.h"
33 /** A simple base implementation for reference-counted components.
34 acts like sal::SimpleReferenceObject but calls the virtual disposing()
35 methods before the ref count switches from 1 to zero.
37 class SimpleReferenceComponent
40 SimpleReferenceComponent();
43 The results are undefined if, for any individual instance of
44 SimpleReferenceComponent, the total number of calls to acquire() exceeds
45 the total number of calls to release() by a platform dependent amount
46 (which, hopefully, is quite large).
48 SD_DLLPUBLIC
void acquire();
49 SD_DLLPUBLIC
void release();
53 bool isDisposed() const { return mbDisposed
; }
55 /** see general class documentation
57 static void * operator new(std::size_t nSize
) SAL_THROW((std::bad_alloc
));
59 /** see general class documentation
61 static void * operator new(std::size_t nSize
,
62 std::nothrow_t
const & rNothrow
)
65 /** see general class documentation
67 static void operator delete(void * pPtr
);
69 /** see general class documentation
71 static void operator delete(void * pPtr
, std::nothrow_t
const & rNothrow
)
75 virtual void disposing();
77 virtual ~SimpleReferenceComponent();
80 oslInterlockedCount m_nCount
;
85 SimpleReferenceComponent(SimpleReferenceComponent
&);
90 void operator =(SimpleReferenceComponent
);
92 /** not implemented (see general class documentation)
95 static void * operator new[](std::size_t);
97 /** not implemented (see general class documentation)
100 static void operator delete[](void * pPtr
);
107 #endif // _SALHELPER_SimpleReferenceComponent_HXX_
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */