File indexing completed on 2024-07-21 05:07:55

0001 /***************************************************************************
0002  *   Copyright (C) 2003 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 #include "microlibrary.h"
0012 #include "microinfo.h"
0013 
0014 // #include <QDebug>
0015 // #include <k3staticdeleter.h>
0016 
0017 #include "picinfo12bit.h"
0018 #include "picinfo14bit.h"
0019 #include "picinfo16bit.h"
0020 
0021 #include "micropackage.h"
0022 
0023 #include <QGlobalStatic>
0024 
0025 // MicroLibrary * MicroLibrary::m_pSelf = nullptr;
0026 // static K3StaticDeleter<MicroLibrary> staticMicroLibraryDeleter;
0027 
0028 Q_GLOBAL_STATIC(MicroLibrary, globalMicroLibrary);
0029 
0030 MicroLibrary *MicroLibrary::self()
0031 {
0032     return globalMicroLibrary;
0033     //  if ( !m_pSelf )
0034     //      staticMicroLibraryDeleter.setObject( m_pSelf, new MicroLibrary() );
0035     //  return m_pSelf;
0036 }
0037 
0038 MicroLibrary::MicroLibrary()
0039 {
0040     addMicroInfo(new PicInfo12C508());
0041     addMicroInfo(new PicInfo12C509());
0042     addMicroInfo(new PicInfo16C54());
0043     addMicroInfo(new PicInfo16C55());
0044     addMicroInfo(new PicInfo16C61());
0045     addMicroInfo(new PicInfo16C62());
0046     addMicroInfo(new PicInfo16C63());
0047     addMicroInfo(new PicInfo16C64());
0048     addMicroInfo(new PicInfo16F627());
0049     addMicroInfo(new PicInfo16F628());
0050     addMicroInfo(new PicInfo16C65());
0051     addMicroInfo(new PicInfo16C71());
0052     addMicroInfo(new PicInfo16C72());
0053     addMicroInfo(new PicInfo16C73());
0054     addMicroInfo(new PicInfo16C712());
0055     addMicroInfo(new PicInfo16C716());
0056     addMicroInfo(new PicInfo16C74());
0057     addMicroInfo(new PicInfo16C84());
0058     addMicroInfo(new PicInfo16CR83());
0059     addMicroInfo(new PicInfo16F83());
0060     addMicroInfo(new PicInfo16CR84());
0061     addMicroInfo(new PicInfo16F84());
0062     addMicroInfo(new PicInfo16F873());
0063     addMicroInfo(new PicInfo16F874());
0064     addMicroInfo(new PicInfo16F877());
0065     addMicroInfo(new PicInfo17C752());
0066     addMicroInfo(new PicInfo17C756());
0067     addMicroInfo(new PicInfo17C762());
0068     addMicroInfo(new PicInfo17C766());
0069     addMicroInfo(new PicInfo18C242());
0070     addMicroInfo(new PicInfo18C252());
0071     addMicroInfo(new PicInfo18C442());
0072     addMicroInfo(new PicInfo18C452());
0073     addMicroInfo(new PicInfo18F442());
0074     addMicroInfo(new PicInfo18F452());
0075 }
0076 
0077 MicroLibrary::~MicroLibrary()
0078 {
0079     qDeleteAll(m_microInfoList);
0080 }
0081 
0082 MicroInfo *MicroLibrary::microInfoWithID(QString id)
0083 {
0084     id = id.toUpper();
0085     const MicroInfoList::iterator end = m_microInfoList.end();
0086     for (MicroInfoList::iterator it = m_microInfoList.begin(); it != end; ++it) {
0087         if ((*it)->id() == id)
0088             return *it;
0089     }
0090 
0091     return nullptr;
0092 }
0093 
0094 void MicroLibrary::addMicroInfo(MicroInfo *microInfo)
0095 {
0096     if (microInfo)
0097         m_microInfoList += microInfo;
0098 }
0099 
0100 QStringList MicroLibrary::microIDs(unsigned asmSet, unsigned gpsimSupport, unsigned flowCodeSupport, unsigned microbeSupport)
0101 {
0102     QStringList ids;
0103 
0104     const MicroInfoList::iterator end = m_microInfoList.end();
0105     for (MicroInfoList::iterator it = m_microInfoList.begin(); it != end; ++it) {
0106         MicroInfo *info = *it;
0107         if ((info->instructionSet()->set() & asmSet) && (info->gpsimSupport() & gpsimSupport) && (info->flowcodeSupport() & flowCodeSupport) && (info->microbeSupport() & microbeSupport))
0108             ids << info->id();
0109     }
0110     return ids;
0111 }