AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simplereferenceobject.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 
4 #ifndef INCLUDED_SALHELPER_SIMPLEREFERENCEOBJECT_HXX
5 #define INCLUDED_SALHELPER_SIMPLEREFERENCEOBJECT_HXX
6 
7 #include "osl/interlck.h"
9 
10 #include <cstddef>
11 #include <new>
12 
13 namespace salhelper {
14 
42 {
43 public:
44  SimpleReferenceObject(): m_nCount(0) {}
45 
52  void acquire()
53  { osl_atomic_increment(&m_nCount); }
54 
55  void release()
56  { if (osl_atomic_decrement(&m_nCount) == 0) delete this; }
57 
60  static void * operator new(std::size_t nSize);
61 
64  static void * operator new(std::size_t nSize,
65  std::nothrow_t const & rNothrow);
66 
69  static void operator delete(void * pPtr);
70 
73  static void operator delete(void * pPtr, std::nothrow_t const & rNothrow);
74 
75 protected:
77 
79 
80 private:
84 
87  void operator =(SimpleReferenceObject) SAL_DELETED_FUNCTION;
88 
91  static void * operator new[](std::size_t) SAL_DELETED_FUNCTION;
92 
95  static void operator delete[](void * pPtr) SAL_DELETED_FUNCTION;
96 };
97 
98 }
99 
100 #endif // INCLUDED_SALHELPER_SIMPLEREFERENCEOBJECT_HXX
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void acquire()
Definition: simplereferenceobject.hxx:52
#define COVERITY_NOEXCEPT_FALSE
To markup destructors that coverity warns might throw exceptions which won&#39;t throw in practice...
Definition: types.h:329
A simple base implementation for reference-counted objects.
Definition: simplereferenceobject.hxx:41
sal_Int32 oslInterlockedCount
Definition: interlck.h:24
SimpleReferenceObject()
Definition: simplereferenceobject.hxx:44
void release()
Definition: simplereferenceobject.hxx:55
#define SALHELPER_DLLPUBLIC
Definition: salhelperdllapi.h:12
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358