00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef HIDDEN_FROM_DOC
00022
00023 #ifndef _SB_PIMPL_MACRO_H_
00024 #define _SB_PIMPL_MACRO_H_
00025
00026
00027
00028
00029
00030
00031
00032
00033 #define OIV_PIMPL_CXX11 0
00034
00035 #if !(OIV_PIMPL_CXX11)
00036 #include <Inventor/misc/SoRefCounter.h>
00037 #else
00038 #include <memory>
00039 #endif
00040
00148 namespace inventor
00149 {
00150 namespace impl
00151 {
00152
00156 template<typename PublicType>
00157 #if !(OIV_PIMPL_CXX11)
00158 class SbPImpl : public SoRefCounter
00159 #else
00160 class SbPImpl
00161 #endif
00162 {
00163 public:
00164
00168 SbPImpl( PublicType* p ) : m_public(p) {}
00169
00173 virtual ~SbPImpl() {}
00174
00178 template<typename SuperPublicType>
00179 SuperPublicType* getPublic () const { return static_cast<SuperPublicType*>(m_public); }
00180
00181 private:
00182
00183
00184 PublicType* m_public;
00185
00186 private:
00187
00188
00189 SbPImpl () {}
00190 };
00191
00192 }
00193 }
00194
00197 #define SO_PIMPL_PUBLIC_DECLARATION(Class) \
00198 namespace inventor\
00199 {\
00200 namespace impl\
00201 {\
00202 class Class##Impl;\
00203 }\
00204 }
00205
00208 #define SO_PIMPL_BASE_PUBLIC_DECLARATION(Class) SO_PIMPL_PUBLIC_DECLARATION(Class)
00209
00212 #define SO_PIMPL_PUBLIC_HEADER(Class) \
00213 SoINTERNAL private:\
00214 friend class inventor::impl::Class##Impl;\
00215
00216 Class(inventor::impl::Class##Impl *impl);
00217
00223 #define SO_PIMPL_ABSTRACT_PUBLIC_HEADER(Class, ParentClass) \
00224 SoINTERNAL private:\
00225
00226 Class(inventor::impl::ParentClass##Impl *impl);
00227
00231 #define SO_PIMPL_FINAL_PUBLIC_HEADER(Class) \
00232 SoINTERNAL private:\
00233 friend class inventor::impl::Class##Impl;
00234
00238 #if OIV_PIMPL_CXX11 == 0
00239 #define SO_PIMPL_BASE_PUBLIC_HEADER(Class) \
00240 SO_PIMPL_PUBLIC_HEADER(Class) \
00241 SoRef< inventor::impl::SbPImpl< Class > > m_impl; \
00242
00243 template<typename ImplType> \
00244 ImplType* getImpl() const { \
00245 assert(m_impl->getPublic< Class >() == this); \
00246 return static_cast< ImplType *>(m_impl.ptr()); \
00247 } \
00248
00249 void setImpl( inventor::impl::SbPImpl< Class >* impl ) { m_impl = impl; }
00250 #elif OIV_PIMPL_CXX11 == 1
00251 #define SO_PIMPL_BASE_PUBLIC_HEADER(Class) \
00252 SO_PIMPL_PUBLIC_HEADER(Class) \
00253 std::auto_ptr< inventor::impl::SbPImpl< Class > > m_impl; \
00254
00255 template<typename ImplType> \
00256 ImplType* getImpl() const { \
00257 assert(m_impl->getPublic< Class >() == this); \
00258 return static_cast< ImplType *>(m_impl.ptr()); \
00259 } \
00260
00261 void setImpl ( inventor::impl::SbPImpl< Class >* impl ) { m_impl.reset(impl); }
00262 #else
00263 #define SO_PIMPL_BASE_PUBLIC_HEADER(Class) \
00264 SO_PIMPL_PUBLIC_HEADER(Class);\
00265 std::unique_ptr< inventor::impl::SbPImpl< Class > > m_impl; \
00266
00267 template<typename ImplType> \
00268 ImplType* getImpl() const { \
00269 assert(m_impl->getPublic< Class >() == this); \
00270 return static_cast< ImplType *>(m_impl.ptr()); \
00271 } \
00272
00273 void setImpl( inventor::impl::SbPImpl< Class >* impl ) { m_impl.reset( impl ); }
00274 #endif
00275
00276 #endif //_SB_PIMPL_MACRO_H_
00277
00278 #endif // HIDDEN_FROM_DOC
00279