diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/devices/pic/base/pic_config.h | |
download | piklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip |
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/devices/pic/base/pic_config.h')
-rw-r--r-- | src/devices/pic/base/pic_config.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/devices/pic/base/pic_config.h b/src/devices/pic/base/pic_config.h new file mode 100644 index 0000000..185a19e --- /dev/null +++ b/src/devices/pic/base/pic_config.h @@ -0,0 +1,107 @@ +/*************************************************************************** + * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef PIC_CONFIG_H +#define PIC_CONFIG_H + +#include <qmap.h> +#include <qstringlist.h> + +#include "common/common/bitvalue.h" +#include "pic_protection.h" +#include "pic.h" + +namespace Pic +{ +class Data; + +BEGIN_DECLARE_ENUM(ConfigNameType) + Default = 0, Extra, SDCC +END_DECLARE_ENUM_STD(ConfigNameType) + +class Config +{ +public: + class Value { + public: + QString name; + QMap<ConfigNameType, QStringList> configNames; + BitValue value; + bool operator <(const Value &cv) const { return value<cv.value; } + bool isValid() const { return !name.isEmpty(); } + }; + + class Mask { + public: + QString name; + BitValue value; + QValueVector<Value> values; // ordered from lower to higher + bool operator <(const Mask &cm) const { return value<cm.value; } + }; + + class Word { + public: + QString name; + QStringList ignoredCNames; + BitValue wmask, pmask, cmask; // write, protected, and checksum bits masks + BitValue bvalue; // blank value + QValueVector<Mask> masks; // ordered from lower to higher + BitValue usedMask() const; + }; + +public: + Config(const Pic::Data &data) : _data(data), _protection(data, *this) {} + QValueVector<Word> _words; + const Protection &protection() const { return _protection; } + + const Value *findValue(const QString &mask, const QString &value) const; + const Mask *findMask(const QString &mask, uint *wordIndex = 0) const; + static bool hasMaskName(const QString &mask); + static QString maskLabel(const QString &mask); + bool checkValueName(const QString &mask, const QString &name) const; + static QString valueLabel(const QString &mask, const QString &name); + +private: + class MapData { + public: + MapData() {} + MapData(int i, int b) : index(i), block(b) {} + int index, block; + }; + static QMap<QString, MapData> &masks(); + static QMap<QString, MapData> *_masks; // mask name -> index in DATA + + struct NameData { + const char *name, *label; + }; + enum Type { Fixed, ValueDouble, ValueUInt, Ratio, MemoryRange, Toggle, Pin, Pins }; + class Data { + public: + const NameData mask; + Type type; + const NameData values[50]; + }; + static const Data DATA[]; + +private: + const Pic::Data &_data; + Protection _protection; +}; + +QDataStream &operator <<(QDataStream &s, const Config::Value &value); +QDataStream &operator >>(QDataStream &s, Config::Value &value); +QDataStream &operator <<(QDataStream &s, const Config::Mask &mask); +QDataStream &operator >>(QDataStream &s, Config::Mask &mask); +QDataStream &operator <<(QDataStream &s, const Config::Word &word); +QDataStream &operator >>(QDataStream &s, Config::Word &word); +QDataStream &operator <<(QDataStream &s, const Config &config); +QDataStream &operator >>(QDataStream &s, Config &config); + +} //namespace + +#endif |