1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: simplereferencecomponent.hxx,v $
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"
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
51 SimpleReferenceComponent();
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();
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
)
86 virtual void disposing();
88 virtual ~SimpleReferenceComponent();
91 oslInterlockedCount m_nCount
;
96 SimpleReferenceComponent(SimpleReferenceComponent
&);
101 void operator =(SimpleReferenceComponent
);
103 /** not implemented (see general class documentation)
106 static void * operator new[](std::size_t);
108 /** not implemented (see general class documentation)
111 static void operator delete[](void * pPtr
);
118 #endif // _SALHELPER_SimpleReferenceComponent_HXX_