sharedmacros.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  sharedmacros.h
00004  * 
00005  *  Created by Aidan Lane on Fri Oct 28 2005.
00006  *  Copyright (c) 2005-2006 Optimisation and Constraint Solving Group,
00007  *  Monash University. All rights reserved.
00008  *
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022  */
00023 
00024 #ifndef SHAREDMACROS_H
00025 #define SHAREDMACROS_H
00026 
00027 
00028 #include <QObject>
00029 
00030 
00031 #ifndef DECLARE_CLASS_TYPE(TYPE)
00032 #define DECLARE_CLASS_TYPE(TYPE)                \
00033   static int classType() { return TYPE; }       \
00034   virtual int type() const { return TYPE; }
00035 #endif
00036 
00037 
00038 #ifndef DECLARE_CLASS_CATEGORY(CATEGORY)
00039 #define DECLARE_CLASS_CATEGORY(CATEGORY)                \
00040   static int classCategory() { return CATEGORY; }       \
00041   virtual int category() const { return CATEGORY; }
00042 #endif
00043 
00044 
00045 #ifndef DECLARE_CLASS_KEY(KEY)
00046 #define DECLARE_CLASS_KEY(KEY)                                  \
00047   static const QByteArray& classKey() {                         \
00048     static const QByteArray str(KEY);                           \
00049     return str;                                                 \
00050   }                                                             \
00051   virtual const QByteArray& key() const { return classKey(); }
00052 #endif
00053 
00054 #ifndef DECLARE_CLASS_KEY_NONREF(KEY)
00055 #define DECLARE_CLASS_KEY_NONREF(KEY)                           \
00056   static QByteArray classKey() {                                \
00057     static const QByteArray str(KEY);                           \
00058     return str;                                                 \
00059   }                                                             \
00060   virtual QByteArray key() const { return classKey(); }
00061 #endif
00062 
00063 
00064 #ifndef DECLARE_CLASS_TITLE(TITLE)
00065 #define DECLARE_CLASS_TITLE(TITLE)                              \
00066   static const QString& classTitle() {                          \
00067     static const QString str( QObject::tr(TITLE) );             \
00068     return str;                                                 \
00069   }                                                             \
00070   virtual const QString& title() const { return classTitle(); }
00071 #endif
00072 
00073 #ifndef DECLARE_CLASS_TITLE_NONREF(TITLE)
00074 #define DECLARE_CLASS_TITLE_NONREF(TITLE)                       \
00075   static QString classTitle() {                                 \
00076     static const QString str( QObject::tr(TITLE) );             \
00077     return str;                                                 \
00078   }                                                             \
00079   virtual QString title() const { return classTitle(); }
00080 #endif
00081 
00082 // Non tr() version, in case you want to pass a QString (rare):
00083 #ifndef DECLARE_CLASS_TITLE_NONTR(TITLE)
00084 #define DECLARE_CLASS_TITLE_NONTR(TITLE)                        \
00085   static const QString& classTitle() {                          \
00086     static const QString str( TITLE );                          \
00087     return str;                                                 \
00088   }                                                             \
00089   virtual const QString& title() const { return classTitle(); }
00090 #endif
00091 
00092 
00093 #ifndef DECLARE_CLASS_DESCRIPTION(DESCRIPTION)
00094 #define DECLARE_CLASS_DESCRIPTION(DESCRIPTION)                          \
00095   static const QString& classDescription() {                            \
00096     static const QString str( QObject::tr(DESCRIPTION) );               \
00097     return str;                                                         \
00098   }                                                                     \
00099   virtual const QString& description() const { return classDescription(); }
00100 #endif
00101 
00102 #ifndef DECLARE_CLASS_DESCRIPTION_NONREF(DESCRIPTION)
00103 #define DECLARE_CLASS_DESCRIPTION_NONREF(DESCRIPTION)                   \
00104   static QString classDescription() {                                   \
00105     static const QString str( QObject::tr(DESCRIPTION) );               \
00106     return str;                                                         \
00107   }                                                                     \
00108   virtual QString description() const { return classDescription(); }
00109 #endif
00110 
00111 // Non tr() version, in case you want to pass a QString (rare):
00112 #ifndef DECLARE_CLASS_DESCRIPTION_NONTR(DESCRIPTION)
00113 #define DECLARE_CLASS_DESCRIPTION_NONTR(DESCRIPTION)                    \
00114   static const QString& classDescription() {                            \
00115     static const QString str( DESCRIPTION );                            \
00116     return str;                                                         \
00117   }                                                                     \
00118   virtual const QString& description() const { return classDescription(); }
00119 #endif
00120 
00121 #ifndef DECLARE_CLASS_DESCRIPTION_METHODS
00122 #define DECLARE_CLASS_DESCRIPTION_METHODS                               \
00123   static const QString& classDescription();                             \
00124   virtual const QString& description() const { return classDescription(); }
00125 #endif
00126 
00127 #ifndef DECLARE_CLASS_DESCRIPTION_METHODS_NONREF
00128 #define DECLARE_CLASS_DESCRIPTION_METHODS_NONREF                        \
00129   static QString classDescription();                                    \
00130   virtual QString description() const { return classDescription(); }
00131 #endif
00132 
00133 
00134 #endif  // ! SHAREDMACROS_H

Generated on Mon Jul 30 09:46:50 2007 for Digest by  doxygen 1.5.2