Pimpl.h
1 //##################################################################################################
2 //
3 // Ceetron 3D Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2011, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 // Needed for std::auto_ptr
16 #include <memory>
17 
18 #ifdef WIN32
19 
20 // Disable 4251, only used in private: so it is not accessible for users of the DLL
21 #define CEE_PRIVATE_IMPL(Class) \
22 __pragma(warning (push)) \
23 __pragma(warning (disable: 4251)) \
24 std::auto_ptr<class Class##Private> m_pimpl; \
25 __pragma(warning (pop))
26 
27 #else
28 
29 #define CEE_PRIVATE_IMPL(Class) \
30 std::auto_ptr<class Class##Private> m_pimpl
31 
32 #endif
33 
34 #define CEE_BASE_F(Class) \
35 friend class Class
36 
37 #define CEE_PRIVATE_F(Class) \
38 friend class Class##Private
39 
40 #define CEE_PRIVATE_INIT(Class) \
41 m_pimpl = std::auto_ptr<Class##Private>(new Class##Private)
42 
43 #define CEE_PRIVATE_INIT_PARAM1(Class, ConstrutorParam1) \
44 m_pimpl = std::auto_ptr<Class##Private>(new Class##Private(ConstrutorParam1))
45 
46 #define CEE_PRIVATE_INIT_PARAM2(Class, ConstrutorParam1, ConstrutorParam2) \
47 m_pimpl = std::auto_ptr<Class##Private>(new Class##Private(ConstrutorParam1, ConstrutorParam2))
48 
49 #define CEE_PRIVATE_INIT_PARAM3(Class, ConstrutorParam1, ConstrutorParam2, ConstrutorParam3) \
50 m_pimpl = std::auto_ptr<Class##Private>(new Class##Private(ConstrutorParam1, ConstrutorParam2, ConstrutorParam3))
51 
52 #define CEE_PRIVATE_INIT_PARAM4(Class, ConstrutorParam1, ConstrutorParam2, ConstrutorParam3, ConstrutorParam4) \
53 m_pimpl = std::auto_ptr<Class##Private>(new Class##Private(ConstrutorParam1, ConstrutorParam2, ConstrutorParam3, ConstrutorParam4))