merge the formfield patch from ooo-build
[ooovba.git] / sd / inc / helper / simplereferencecomponent.hxx
blob3f215e5876cbe065d9d8e12e6279452e1b88df77
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: simplereferencecomponent.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SD_SIMPLEREFERENCECOMPONENT_HXX_
32 #define _SD_SIMPLEREFERENCECOMPONENT_HXX_
34 #include "osl/interlck.h"
35 #include "sal/types.h"
37 #include <cstddef>
38 #include <new>
40 #include <sddllapi.h>
42 namespace sd {
44 /** A simple base implementation for reference-counted components.
45 acts like sal::SimpleReferenceObject but calls the virtual disposing()
46 methods before the ref count switches from 1 to zero.
48 class SimpleReferenceComponent
50 public:
51 SimpleReferenceComponent();
53 /** @ATTENTION
54 The results are undefined if, for any individual instance of
55 SimpleReferenceComponent, the total number of calls to acquire() exceeds
56 the total number of calls to release() by a plattform dependent amount
57 (which, hopefully, is quite large).
59 SD_DLLPUBLIC void acquire();
60 SD_DLLPUBLIC void release();
62 void Dispose();
64 bool isDisposed() const { return mbDisposed; }
66 /** see general class documentation
68 static void * operator new(std::size_t nSize) SAL_THROW((std::bad_alloc));
70 /** see general class documentation
72 static void * operator new(std::size_t nSize,
73 std::nothrow_t const & rNothrow)
76 /** see general class documentation
78 static void operator delete(void * pPtr);
80 /** see general class documentation
82 static void operator delete(void * pPtr, std::nothrow_t const & rNothrow)
85 protected:
86 virtual void disposing();
88 virtual ~SimpleReferenceComponent();
90 private:
91 oslInterlockedCount m_nCount;
93 /** not implemented
94 @internal
96 SimpleReferenceComponent(SimpleReferenceComponent &);
98 /** not implemented
99 @internal
101 void operator =(SimpleReferenceComponent);
103 /** not implemented (see general class documentation)
104 @internal
106 static void * operator new[](std::size_t);
108 /** not implemented (see general class documentation)
109 @internal
111 static void operator delete[](void * pPtr);
113 bool mbDisposed;
118 #endif // _SALHELPER_SimpleReferenceComponent_HXX_