CWS-TOOLING: integrate CWS os150
[LibreOffice.git] / sd / inc / helper / simplereferencecomponent.hxx
blob115457286663ff7ca4e1487c214c31be7b2315a3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _SD_SIMPLEREFERENCECOMPONENT_HXX_
29 #define _SD_SIMPLEREFERENCECOMPONENT_HXX_
31 #include "osl/interlck.h"
32 #include "sal/types.h"
34 #include <cstddef>
35 #include <new>
37 #include <sddllapi.h>
39 namespace sd {
41 /** A simple base implementation for reference-counted components.
42 acts like sal::SimpleReferenceObject but calls the virtual disposing()
43 methods before the ref count switches from 1 to zero.
45 class SimpleReferenceComponent
47 public:
48 SimpleReferenceComponent();
50 /** @ATTENTION
51 The results are undefined if, for any individual instance of
52 SimpleReferenceComponent, the total number of calls to acquire() exceeds
53 the total number of calls to release() by a plattform dependent amount
54 (which, hopefully, is quite large).
56 SD_DLLPUBLIC void acquire();
57 SD_DLLPUBLIC void release();
59 void Dispose();
61 bool isDisposed() const { return mbDisposed; }
63 /** see general class documentation
65 static void * operator new(std::size_t nSize) SAL_THROW((std::bad_alloc));
67 /** see general class documentation
69 static void * operator new(std::size_t nSize,
70 std::nothrow_t const & rNothrow)
73 /** see general class documentation
75 static void operator delete(void * pPtr);
77 /** see general class documentation
79 static void operator delete(void * pPtr, std::nothrow_t const & rNothrow)
82 protected:
83 virtual void disposing();
85 virtual ~SimpleReferenceComponent();
87 private:
88 oslInterlockedCount m_nCount;
90 /** not implemented
91 @internal
93 SimpleReferenceComponent(SimpleReferenceComponent &);
95 /** not implemented
96 @internal
98 void operator =(SimpleReferenceComponent);
100 /** not implemented (see general class documentation)
101 @internal
103 static void * operator new[](std::size_t);
105 /** not implemented (see general class documentation)
106 @internal
108 static void operator delete[](void * pPtr);
110 bool mbDisposed;
115 #endif // _SALHELPER_SimpleReferenceComponent_HXX_