21#ifndef HIDDEN_FROM_DOC
23#ifndef _SB_PIMPL_MACRO_H_
24#define _SB_PIMPL_MACRO_H_
33#define OIV_PIMPL_CXX11 0
36#include <Inventor/misc/SoRefCounter.h>
156template<
typename PublicType>
157#if !(OIV_PIMPL_CXX11)
168 SbPImpl( PublicType* p ) : m_public(p) {}
173 virtual ~SbPImpl() {}
178 template<
typename SuperPublicType>
179 SuperPublicType* getPublic ()
const {
return static_cast<SuperPublicType*
>(m_public); }
184 PublicType* m_public;
197#define SO_PIMPL_PUBLIC_DECLARATION(Class) \
208#define SO_PIMPL_BASE_PUBLIC_DECLARATION(Class) SO_PIMPL_PUBLIC_DECLARATION(Class)
212#define SO_PIMPL_PUBLIC_HEADER(Class) \
214 friend class inventor::impl::Class##Impl;\
216 Class(inventor::impl::Class##Impl *impl);
223#define SO_PIMPL_ABSTRACT_PUBLIC_HEADER(Class, ParentClass) \
226 Class(inventor::impl::ParentClass##Impl *impl);
231#define SO_PIMPL_FINAL_PUBLIC_HEADER(Class) \
233 friend class inventor::impl::Class##Impl;
238#if OIV_PIMPL_CXX11 == 0
239#define SO_PIMPL_BASE_PUBLIC_HEADER(Class) \
240SO_PIMPL_PUBLIC_HEADER(Class) \
241 SoRef< inventor::impl::SbPImpl< Class > > m_impl; \
243 template<
typename ImplType> \
244 ImplType* getImpl()
const { \
245 assert(m_impl->getPublic< Class >() ==
this); \
246 return static_cast< ImplType *
>(m_impl.ptr()); \
249 void setImpl( inventor::impl::SbPImpl< Class >* impl ) { m_impl = impl; }
250#elif OIV_PIMPL_CXX11 == 1
251#define SO_PIMPL_BASE_PUBLIC_HEADER(Class) \
252SO_PIMPL_PUBLIC_HEADER(Class) \
253 std::auto_ptr< inventor::impl::SbPImpl< Class > > m_impl; \
255 template<
typename ImplType> \
256 ImplType* getImpl()
const { \
257 assert(m_impl->getPublic< Class >() ==
this); \
258 return static_cast< ImplType *
>(m_impl.ptr()); \
261 void setImpl ( inventor::impl::SbPImpl< Class >* impl ) { m_impl.reset(impl); }
263#define SO_PIMPL_BASE_PUBLIC_HEADER(Class) \
264SO_PIMPL_PUBLIC_HEADER(Class);\
265 std::unique_ptr< inventor::impl::SbPImpl< Class > > m_impl; \
267 template<
typename ImplType> \
268 ImplType* getImpl()
const { \
269 assert(m_impl->getPublic< Class >() ==
this); \
270 return static_cast< ImplType *
>(m_impl.ptr()); \
273 void setImpl( inventor::impl::SbPImpl< Class >* impl ) { m_impl.reset( impl ); }
Base class for ref-counted objects.