bump product version to 4.1.6.2
[LibreOffice.git] / sd / inc / helper / simplereferencecomponent.hxx
blob85b264e72196fc52814087ac94c9debf50eb0f30
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
26 #include <cstddef>
27 #include <new>
29 #include <sddllapi.h>
31 namespace sd {
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
39 public:
40 SimpleReferenceComponent();
42 /** @ATTENTION
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();
51 void Dispose();
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)
74 protected:
75 virtual void disposing();
77 virtual ~SimpleReferenceComponent();
79 private:
80 oslInterlockedCount m_nCount;
82 /** not implemented
83 @internal
85 SimpleReferenceComponent(SimpleReferenceComponent &);
87 /** not implemented
88 @internal
90 void operator =(SimpleReferenceComponent);
92 /** not implemented (see general class documentation)
93 @internal
95 static void * operator new[](std::size_t);
97 /** not implemented (see general class documentation)
98 @internal
100 static void operator delete[](void * pPtr);
102 bool mbDisposed;
107 #endif // _SALHELPER_SimpleReferenceComponent_HXX_
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */