autoqpointer_p.h

00001 /*
00002  *  autoqpointer.h  -  QPointer which on destruction deletes object
00003  *  This is a (mostly) verbatim, private copy of kdepim/kalarm/lib/autoqpointer.h
00004  *
00005  *  Copyright © 2009 by David Jarvie <djarvie@kde.org>
00006  *
00007  *  This library is free software; you can redistribute it and/or modify it
00008  *  under the terms of the GNU Library General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or (at your
00010  *  option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful, but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015  *  License for more details.
00016  *
00017  *  You should have received a copy of the GNU Library General Public License
00018  *  along with this library; see the file COPYING.LIB.  If not, write to the
00019  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  *  02110-1301, USA.
00021  */
00022 
00023 #ifndef AUTOQPOINTER_H
00024 #define AUTOQPOINTER_H
00025 
00026 #include <QPointer>
00027 
00028 
00034 template <class T>
00035 class AutoQPointer : public QPointer<T>
00036 {
00037   public:
00038     inline AutoQPointer() : QPointer<T>() {}
00039     inline AutoQPointer(T* p) : QPointer<T>(p) {}
00040     inline AutoQPointer(const QPointer<T>& p) : QPointer<T>(p) {}
00041     inline ~AutoQPointer()  { delete this->data(); }
00042     inline AutoQPointer<T>& operator=(const AutoQPointer<T>& p) { QPointer<T>::operator=(p); return *this; }
00043     inline AutoQPointer<T>& operator=(T* p) { QPointer<T>::operator=(p); return *this; }
00044 };
00045 
00046 #endif // AUTOQPOINTER_H
KDE Home | KDE Accessibility Home | Description of Access Keys