Eneboo - Documentación para desarrolladores
src/qt/src/kernel/qlock_p.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qlock_p.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** Definition of QLock class. This manages interprocess locking
00005 **
00006 ** Created : 20000406
00007 **
00008 ** Copyright (C) 2000-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed and/or modified under the terms of the
00013 ** GNU General Public License version 2 as published by the Free Software
00014 ** Foundation and appearing in the file LICENSE.GPL included in the
00015 ** packaging of this file.
00016 **
00017 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00018 ** licenses for Qt/Embedded may use this file in accordance with the
00019 ** Qt Embedded Commercial License Agreement provided with the Software.
00020 **
00021 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00022 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00023 **
00024 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00025 **   information about Qt Commercial License Agreements.
00026 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00027 **
00028 ** Contact info@trolltech.com if any conditions of this licensing are
00029 ** not clear to you.
00030 **
00031 **********************************************************************/
00032 
00033 #ifndef QLOCK_P_H
00034 #define QLOCK_P_H
00035 
00036 //
00037 //  W A R N I N G
00038 //  -------------
00039 //
00040 // This file is not part of the Qt API.  This header file may
00041 // change from version to version without notice, or even be
00042 // removed.
00043 //
00044 // We mean it.
00045 //
00046 //
00047 
00048 #ifndef QT_H
00049 #include "qstring.h"
00050 #endif // QT_H
00051 
00052 class QLockData;
00053 
00054 class QLock
00055 {
00056 public:
00057     QLock( const QString &filename, char id, bool create = FALSE );
00058     ~QLock();
00059 
00060     enum Type { Read, Write };
00061 
00062     bool isValid() const;
00063     void lock( Type type );
00064     void unlock();
00065     bool locked() const;
00066 
00067 private:
00068     Type type;
00069     QLockData *data;
00070 };
00071 
00072 
00073 // Nice class for ensuring the lock is released.
00074 // Just create one on the stack and the lock is automatically released
00075 // when QLockHolder is destructed.
00076 class QLockHolder
00077 {
00078 public:
00079     QLockHolder( QLock *l, QLock::Type type ) : qlock(l) {
00080         qlock->lock( type );
00081     }
00082     ~QLockHolder() { if ( locked() ) qlock->unlock(); }
00083 
00084     void lock( QLock::Type type ) { qlock->lock( type ); }
00085     void unlock() { qlock->unlock(); }
00086     bool locked() const { return qlock->locked(); }
00087 
00088 private:
00089     QLock *qlock;
00090 };
00091 
00092 #endif
00093 
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'