File indexing completed on 2024-04-14 05:36:27

0001 /***************************************************************************
0002  *   Copyright (C) 2004-2005 by Daniel Clarke   daniel.jc@gmail.com        *
0003  *   Copyright (C)      2005 by David Saxton                               *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #ifndef VARIABLE_H
0022 #define VARIABLE_H
0023 
0024 #include <QString>
0025 #include <QList>
0026 
0027 class PortPin;
0028 typedef QList<PortPin> PortPinList;
0029 
0030 
0031 /**
0032 @author Daniel Clarke
0033 @author David Saxton
0034 */
0035 class Variable
0036 {
0037     public:
0038         enum VariableType
0039         {
0040             charType, // 8 bit file register
0041             sevenSegmentType, // A pin configuration for a seven segment is represented by a write-only variable.
0042             keypadType, // A pin configuration for a keypad has 4 rows and n columns (typically n = 3 or 4) - a read-only variable
0043             invalidType
0044         };
0045         
0046         Variable( VariableType type, const QString & name );
0047         Variable();
0048         ~Variable();
0049 
0050         VariableType type() const { return m_type; }
0051         QString name() const { return m_name; }
0052         
0053         /**
0054          * @returns whether the variable can be read from (e.g. the seven
0055          * segment variable cannot).
0056          */
0057         bool isReadable() const;
0058         /**
0059          * @returns whether the variable can be written to (e.g. the keypad
0060          * variable cannot).
0061          */
0062         bool isWritable() const;
0063         /**
0064          * @see portPinList
0065          */
0066         void setPortPinList( const PortPinList & portPinList );
0067         /**
0068          * Used in seven-segments and keypads,
0069          */
0070         PortPinList portPinList() const { return m_portPinList; }
0071         
0072     protected:
0073         VariableType m_type;
0074         QString m_name;
0075         PortPinList m_portPinList;
0076 };
0077 typedef QList<Variable> VariableList;
0078 
0079 #endif