File indexing completed on 2025-02-16 08:27:14
0001 /*************************************************************************** 0002 * Copyright (C) 2005 by David Saxton * 0003 * david@bluehaze.org * 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 0011 #ifndef PICPROGRAMMER_H 0012 #define PICPROGRAMMER_H 0013 0014 #include "externallanguage.h" 0015 0016 #include <QMap> 0017 0018 class KConfig; 0019 class KProcess; 0020 0021 class ProgrammerConfig 0022 { 0023 public: 0024 ProgrammerConfig(); 0025 0026 /** 0027 * Clears the type and all commands. 0028 */ 0029 void reset(); 0030 0031 QString initCommand; 0032 QString readCommand; 0033 QString writeCommand; 0034 QString verifyCommand; 0035 QString blankCheckCommand; 0036 QString eraseCommand; 0037 0038 QString description; 0039 QString executable; // The name of the program executable 0040 }; 0041 0042 typedef QMap<QString, ProgrammerConfig> ProgrammerConfigMap; 0043 0044 /** 0045 This class provides access to the PIC Programmer configurations. Several are 0046 predefinied; the rest can be read from and written to, and removed. Names are 0047 case insensitive. 0048 0049 Each programmer configuration is in the form of the ProgrammerConfig struct. 0050 0051 @author David Saxton 0052 */ 0053 class PicProgrammerSettings 0054 { 0055 public: 0056 PicProgrammerSettings(); 0057 0058 /** 0059 * Reads in custom ProgrammerConfigs from config. Any previously loaded 0060 * configurations stored in this class will removed first. 0061 */ 0062 void load(KConfig *config); 0063 /** 0064 * Saves the custom ProgrammConfigs to config. 0065 */ 0066 void save(KConfig *config); 0067 /** 0068 * @return the ProgrammConfig for the programmer with the given name. If 0069 * no such ProgrammerConfigs with the given name exist, then one will be 0070 * created. The name is case insensitive (although the full case of the 0071 * name will be stored if a new ProgrammerConfig is created). 0072 */ 0073 ProgrammerConfig config(const QString &name); 0074 /** 0075 * Removes the config (if it is custom) with the give name. 0076 */ 0077 void removeConfig(const QString &name); 0078 /** 0079 * Sets the ProgrammerConfig with the given name (or creates one if no 0080 * such config exists). The name is case insensitive. 0081 */ 0082 void saveConfig(const QString &name, const ProgrammerConfig &config); 0083 /** 0084 * @param makeLowercase whether the names should be converted to 0085 * lowercase before returning. 0086 * @return a list of names of the custom and predefined configs. 0087 */ 0088 QStringList configNames(bool makeLowercase) const; 0089 /** 0090 * @return whether the given config is predefined. 0091 */ 0092 bool isPredefined(const QString &name) const; 0093 0094 protected: 0095 /** 0096 * Called when a PicProgrammerSettings object is first created. Does 0097 * initialization of the predefined configs. 0098 */ 0099 void initStaticConfigs(); 0100 0101 ProgrammerConfigMap m_customConfigs; 0102 0103 static bool m_bDoneStaticConfigsInit; 0104 static ProgrammerConfigMap m_staticConfigs; 0105 }; 0106 0107 /** 0108 @author David Saxton 0109 */ 0110 class PicProgrammer : public ExternalLanguage 0111 { 0112 public: 0113 PicProgrammer(ProcessChain *processChain); 0114 ~PicProgrammer() override; 0115 0116 void processInput(ProcessOptions options) override; 0117 ProcessOptions::ProcessPath::Path outputPath(ProcessOptions::ProcessPath::Path inputPath) const override; 0118 0119 protected: 0120 bool isError(const QString &message) const override; 0121 bool isWarning(const QString &message) const override; 0122 }; 0123 0124 #endif