MvcCore/genericcontainers.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  genericcontainers.h
00004  *  Digest
00005  * 
00006  *  Created by Aidan Lane on Thu Jun 10 2005.
00007  *  Copyright (c) 2005-2006 Optimisation and Constraint Solving Group,
00008  *  Monash University. All rights reserved.
00009  *
00010  *  This program 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 program 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  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00023  */
00024 
00025 #ifndef GENERALCONTAINERS_H
00026 #define GENERALCONTAINERS_H
00027 
00028 
00029 #include <QSet>
00030 #include <QString>
00031 #include <QVariant>
00032 
00033 typedef QSet<int>  IdSet;
00034 
00035 
00036 class NameContainer {
00037 public:
00038   NameContainer( const QString& name ) : m_name(name) {}
00039   const QString& name() const { return m_name; }
00040 private:
00041   const QString m_name;
00042 };
00043 
00044 
00045 class FilenameContainer {
00046 public:
00047   FilenameContainer( const QString& filename ) : m_filename(filename) {}
00048   const QString& filename() const { return m_filename; }
00049 private:
00050   const QString m_filename;
00051 };
00052 
00053 
00054 class KeyContainer {
00055 public:
00056   KeyContainer( const QString& key ) : m_key(key) {}
00057   const QString& key() const { return m_key; }
00058 private:
00059   const QString m_key;
00060 };
00061 
00062 
00063 class ValueContainer {
00064 public:
00065   ValueContainer( const QVariant& value ) : m_value(value) {}
00066   const QVariant& value() const { return m_value; }
00067 private:
00068   const QVariant m_value;
00069 };
00070 
00071 class DataContainer {
00072 public:
00073   DataContainer( const QVariant& data ) : m_data(data) {}
00074   const QVariant& data() const { return m_data; }
00075 private:
00076   const QVariant m_data;
00077 };
00078 
00079 
00084 class IndexContainer {
00085 public:
00086   IndexContainer( int index ) : m_index(index) {}
00087   int index() const { return m_index; }
00088 private:
00089   int m_index;
00090 };
00091 
00092 
00097 class IdContainer {
00098 public:
00099   IdContainer( int id ) : m_id(id) {}
00100   int id() const { return m_id; }
00101 private:
00102   int m_id;
00103 };
00104 
00105 
00110 class IdSetContainer {
00111 public:
00112   IdSetContainer( const IdSet& idSet ) : m_idSet(idSet) {}
00113   IdSetContainer( int id ) { m_idSet += id; }
00114   const IdSet& idSet() const { return m_idSet; }
00115 private:
00116   IdSet m_idSet;
00117 };
00118 
00119 
00120 template <class T> 
00121 class AddSetContainer {
00122 public:
00123   AddSetContainer( const QSet<T>& addSet ) : m_addSet(addSet) {}
00124   AddSetContainer( T item ) { m_addSet += item; }
00125   const QSet<T>& addSet() const { return m_addSet; }
00126 private:
00127   QSet<T> m_addSet;
00128 };
00129 
00130 
00131 template <class T> 
00132 class RemoveSetContainer {
00133 public:
00134   RemoveSetContainer( const QSet<T>& removeSet ) : m_removeSet(removeSet) {}
00135   RemoveSetContainer( T item ) { m_removeSet += item; }
00136   const QSet<T>& removeSet() const { return m_removeSet; }
00137 private:
00138   QSet<T> m_removeSet;
00139 };
00140 
00141 
00142 #endif //  ! GENERALCONTAINERS_H

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