DeltaQt  Version 0.2.0 End user documentation
A C++/Qt library for parsing DELTA (DEscription Language for TAxonomy) files
F:/Code/DeltaQt/DeltaQt/deltacharacter.h
Go to the documentation of this file.
00001 /*  Copyright 2012 Craig Robbins
00002 
00003     This file is part of DeltaQt
00004 
00005     DeltaQt is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     DeltaQt is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with DeltaQt.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #ifndef DELTACHARACTER_H
00020 #define DELTACHARACTER_H
00021 
00022 #include <QString>
00023 #include <QList>
00024 #include "globals.h"
00025 #include "deltacharactertype.h"
00026 
00027 
00028 class DeltaCharacterState
00029 {
00030 public:
00031     DeltaCharacterState();
00032     DeltaCharacterState(int id, const QString& name);
00033 
00034     inline int id (void) const { return m_id; }
00035 
00036     inline QString name(void) const { return m_name; }
00037 
00038     void set(int id, const QString& name);
00039 
00040 protected:
00041     int m_id;
00042     QString m_name;
00043 };
00044 
00045 typedef QList<DeltaCharacterState> DeltaCharacterStates;
00046 
00047 /****************************************************************************/
00048 
00049 /* Different types of DELTA characters probably should be inherited from the
00050  * base class DeltaCharacter, rather than having their extended attributes
00051  * embedded within DeltaCharacter, however this introduces some problems when
00052  * parsing DELTA text files. When parsing the text files, the character type
00053  * is often 'inferred' and reassigned at a later point in the parsing
00054  * process (e.g. if the CHARLIST directive is processes before the CHARTYPES
00055  * directive; the chars file is read before the specs file).
00056  */
00057 class DeltaCharacter
00058 {
00059 public:
00060     DeltaCharacter();
00061     ~DeltaCharacter();
00062     DeltaCharacter(DeltaCharacterType::TypeId typeId);
00063 
00064     bool isValid(void) const;
00065 
00066     int charNum(void) const;
00067     QString name(void) const;
00068     inline const DeltaCharacterStates states(void) const { return m_states; }
00069     inline QString units(void) const { return m_units; }
00070 
00071     DeltaCharacterType::TypeId type(void) const;
00072     double weight(void) const;
00073 
00074     void addNote(const QString& note);
00075     void addState(int id, const QString& name);
00076     void clear(void);
00077     void setCharType(DeltaCharacterType::TypeId type);
00078     int setDeltaCharNum(int to);
00079     int setReliability(int reliability);
00080     void setUnits(const QString& to);
00081     void setName(const QString& to);
00082 
00083 protected:
00084     void m_initCommon(void);
00085     void m_setDefaults(void);
00086 
00087     DeltaCharacterType::TypeId m_charType;
00088 
00089     // Attributes common to all types
00090     int m_deltaCharNum;
00091     QString m_name;
00092     QList<QString> m_noteList;
00093     QString m_comment;
00094     int m_reliability; 
00095 
00096     // Multistate attributes
00097     DeltaCharacterStates m_states;
00098 
00099     // Numeric attributes
00100     QString m_units;
00101 
00102     // TODO: m_images;
00103 
00104 };
00105 
00106 typedef QList<DeltaCharacter> DeltaCharacterList;
00107 
00108 #if 0   // !!!!!!! DEPRECATED
00109 class DeltaCharacterNote
00110 {
00111 public:
00112     DeltaCharacterNote();
00113     DeltaCharacterNote(int id, QString text);
00114 
00115     int id(void) const;
00116     QString text(void) const;
00117 
00118     void setId(int id);
00119     void setText(const QString& text);
00120 
00121 private:
00122     int m_id;
00123     QString m_text;
00124 };
00125 
00126 typedef QList<DeltaCharacterNote> DeltaCharacterNoteList;
00127 #endif // !!!!!!! DEPRECATED
00128 
00129 
00130 #endif // DELTACHARACTER_H
00131 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines