1 /*************************************************************************** 2 * Copyright (C) 2003 by David Saxton * 3 * david@bluehaze.org * 4 * * 5 * This program is free software; you can redistribute it and/or modify * 6 * it under the terms of the GNU General Public License as published by * 7 * the Free Software Foundation; either version 2 of the License, or * 8 * (at your option) any later version. * 9 ***************************************************************************/ 10 11 #include "microinfo.h" 12 #include "microlibrary.h" 13 14 // #include <QDebug> 15 // #include <k3staticdeleter.h> 16 17 #include "picinfo12bit.h" 18 #include "picinfo14bit.h" 19 #include "picinfo16bit.h" 20 21 #include "micropackage.h" 22 23 #include <QGlobalStatic> 24 25 // MicroLibrary * MicroLibrary::m_pSelf = nullptr; 26 // static K3StaticDeleter<MicroLibrary> staticMicroLibraryDeleter; 27 28 Q_GLOBAL_STATIC( MicroLibrary, globalMicroLibrary); 29 self()30MicroLibrary * MicroLibrary::self() 31 { 32 return globalMicroLibrary; 33 // if ( !m_pSelf ) 34 // staticMicroLibraryDeleter.setObject( m_pSelf, new MicroLibrary() ); 35 // return m_pSelf; 36 } 37 MicroLibrary()38MicroLibrary::MicroLibrary() 39 { 40 addMicroInfo( new PicInfo12C508() ); 41 addMicroInfo( new PicInfo12C509() ); 42 addMicroInfo( new PicInfo16C54 () ); 43 addMicroInfo( new PicInfo16C55() ); 44 addMicroInfo( new PicInfo16C61() ); 45 addMicroInfo( new PicInfo16C62() ); 46 addMicroInfo( new PicInfo16C63() ); 47 addMicroInfo( new PicInfo16C64() ); 48 addMicroInfo( new PicInfo16F627() ); 49 addMicroInfo( new PicInfo16F628() ); 50 addMicroInfo( new PicInfo16C65() ); 51 addMicroInfo( new PicInfo16C71() ); 52 addMicroInfo( new PicInfo16C72() ); 53 addMicroInfo( new PicInfo16C73() ); 54 addMicroInfo( new PicInfo16C712() ); 55 addMicroInfo( new PicInfo16C716() ); 56 addMicroInfo( new PicInfo16C74() ); 57 addMicroInfo( new PicInfo16C84() ); 58 addMicroInfo( new PicInfo16CR83() ); 59 addMicroInfo( new PicInfo16F83() ); 60 addMicroInfo( new PicInfo16CR84() ); 61 addMicroInfo( new PicInfo16F84() ); 62 addMicroInfo( new PicInfo16F873() ); 63 addMicroInfo( new PicInfo16F874() ); 64 addMicroInfo( new PicInfo16F877() ); 65 addMicroInfo( new PicInfo17C752() ); 66 addMicroInfo( new PicInfo17C756() ); 67 addMicroInfo( new PicInfo17C762() ); 68 addMicroInfo( new PicInfo17C766() ); 69 addMicroInfo( new PicInfo18C242() ); 70 addMicroInfo( new PicInfo18C252() ); 71 addMicroInfo( new PicInfo18C442() ); 72 addMicroInfo( new PicInfo18C452() ); 73 addMicroInfo( new PicInfo18F442() ); 74 addMicroInfo( new PicInfo18F452() ); 75 } 76 ~MicroLibrary()77MicroLibrary::~MicroLibrary() 78 { 79 const MicroInfoList::iterator end = m_microInfoList.end(); 80 for ( MicroInfoList::iterator it = m_microInfoList.begin(); it != end; ++it ) { 81 delete *it; 82 } 83 } 84 microInfoWithID(QString id)85MicroInfo *MicroLibrary::microInfoWithID( QString id ) 86 { 87 id = id.toUpper(); 88 const MicroInfoList::iterator end = m_microInfoList.end(); 89 for ( MicroInfoList::iterator it = m_microInfoList.begin(); it != end; ++it ) 90 { 91 if ( (*it)->id() == id ) return *it; 92 } 93 94 return nullptr; 95 } 96 addMicroInfo(MicroInfo * microInfo)97void MicroLibrary::addMicroInfo( MicroInfo *microInfo ) 98 { 99 if (microInfo) 100 m_microInfoList += microInfo; 101 } 102 microIDs(unsigned asmSet,unsigned gpsimSupport,unsigned flowCodeSupport,unsigned microbeSupport)103QStringList MicroLibrary::microIDs( unsigned asmSet, unsigned gpsimSupport, unsigned flowCodeSupport, unsigned microbeSupport ) 104 { 105 QStringList ids; 106 107 const MicroInfoList::iterator end = m_microInfoList.end(); 108 for ( MicroInfoList::iterator it = m_microInfoList.begin(); it != end; ++it ) 109 { 110 MicroInfo * info = *it; 111 if ( (info->instructionSet()->set() & asmSet) && 112 (info->gpsimSupport() & gpsimSupport) && 113 (info->flowcodeSupport() & flowCodeSupport) && 114 (info->microbeSupport() & microbeSupport) ) 115 ids << info->id(); 116 } 117 return ids; 118 } 119