• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pimpl.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2006 J-P Nurmi. All rights reserved.
00004 **
00005 ** This file is written as an example for QtCentre Wiki. The content
00006 ** of this file originate from qglobal.h, which is part of the QtCore 
00007 ** module of the Qt Toolkit:
00008 ** http://www.trolltech.com/products/qt/opensource.html.
00009 **
00010 ** This file is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This file is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 ** GNU General Public License for more details.
00019 **
00020 ****************************************************************************/
00021 
00022 /****************************************************************************
00023 **
00024 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00025 **
00026 ** This file is part of the QtCore module of the Qt Toolkit.
00027 **
00028 ** This file may be used under the terms of the GNU General Public
00029 ** License version 2.0 as published by the Free Software Foundation
00030 ** and appearing in the file LICENSE.GPL included in the packaging of
00031 ** this file.  Please review the following information to ensure GNU
00032 ** General Public Licensing requirements will be met:
00033 ** http://www.trolltech.com/products/qt/opensource.html
00034 **
00035 ** If you are unsure which license is appropriate for your use, please
00036 ** review the following information:
00037 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00038 ** sales department at sales@trolltech.com.
00039 **
00040 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00041 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00042 **
00043 ****************************************************************************/
00044 
00045 #ifndef PIMPL_H
00046 #define PIMPL_H
00047 
00061 #define PIMPL_DECLARE_PRIVATE(Class) \
00062         private: \
00063                 inline Class##Private* priv_func() { return reinterpret_cast<Class##Private *>(priv_ptr); } \
00064                 inline const Class##Private* priv_func() const { return reinterpret_cast<const Class##Private *>(priv_ptr); } \
00065                 friend class Class##Private; \
00066                 void* priv_ptr;
00067 
00068 #define PIMPL_DECLARE_PUBLIC(Class) \
00069         public: \
00070                 inline Class* pub_func() { return static_cast<Class *>(pub_ptr); } \
00071                 inline const Class* pub_func() const { return static_cast<const Class *>(pub_ptr); } \
00072         private: \
00073                 friend class Class; \
00074                 void* pub_ptr;
00075 
00076 #define PIMPL_PRIVATE(Class) Class##Private * const priv = priv_func()
00077 #define PIMPL_PUBLIC(Class) Class * const pub = pub_func()
00078 
00079 #define PIMPL_INITIALIZE(Class) \
00080                 priv_ptr = new Class##Private(); \
00081                 PIMPL_PRIVATE(Class); \
00082                 priv->pub_ptr = this;
00083                 
00084 #define PIMPL_UNINITIALIZE(Class) \
00085                 PIMPL_PRIVATE(Class); \
00086                 delete priv;
00087 
00088 #endif // PIMPL_H

Generated on Tue Aug 24 2010 15:58:55 for Smartlet by  doxygen 1.7.1