fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / tools / mempool.hxx
blob3fa27ff50773a77c1ad80e74c2f01d7f8c607153
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 .
19 #ifndef _SVMEMPOOL_HXX
20 #define _SVMEMPOOL_HXX
22 #include "sal/config.h"
24 #include "sal/macros.h"
25 #include "tools/toolsdllapi.h"
26 #include "tools/solar.h"
28 struct FixedMemPool_Impl;
30 class TOOLS_DLLPUBLIC FixedMemPool
32 FixedMemPool_Impl * m_pImpl;
33 char const * m_pTypeName;
35 public:
36 FixedMemPool( char const * pTypeName,
37 sal_uInt16 nTypeSize );
38 ~FixedMemPool();
40 void* Alloc();
41 void Free( void* p );
44 #define DECL_FIXEDMEMPOOL_NEW_DECL() \
45 static void * operator new( size_t n )
47 #define DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \
48 void * Class::operator new( size_t n )
50 #define IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \
51 { \
52 if ( n == sizeof( Class ) ) \
53 return (aPool).Alloc(); \
54 else \
55 return ::operator new(n); \
58 #define DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \
59 DECL_FIXEDMEMPOOL_NEW_DECL() \
60 IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool )
62 #define DECL_FIXEDMEMPOOL_DEL_DECL() \
63 static void operator delete( void * p, size_t n )
65 #define DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \
66 void Class::operator delete( void * p, size_t n )
68 #define IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) \
69 { \
70 if ( n == sizeof( Class ) ) \
71 (aPool).Free(p); \
72 else \
73 ::operator delete(p); \
76 #define DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool ) \
77 DECL_FIXEDMEMPOOL_DEL_DECL() \
78 IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool )
80 #define DECL_FIXEDMEMPOOL_NEWDEL( Class ) \
81 private: \
82 static FixedMemPool aPool; \
83 public: \
84 DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \
85 DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool )
87 #define IMPL_FIXEDMEMPOOL_NEWDEL( Class ) \
88 FixedMemPool Class::aPool( SAL_STRINGIFY( Class ), sizeof( Class ) );
90 #define DECL_FIXEDMEMPOOL_NEWDEL_DLL( Class ) \
91 private: \
92 static FixedMemPool aPool; \
93 public: \
94 DECL_FIXEDMEMPOOL_NEW_DECL(); \
95 DECL_FIXEDMEMPOOL_DEL_DECL();
97 #define IMPL_FIXEDMEMPOOL_NEWDEL_DLL( Class ) \
98 FixedMemPool Class::aPool( SAL_STRINGIFY( Class ), sizeof( Class ) ); \
99 DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \
100 IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \
101 DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \
102 IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool )
104 #endif
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */