comparison transform/TransformFactory.cpp @ 810:b18f8c5fb4f5

Debug tidy
author Chris Cannam
date Thu, 16 May 2013 14:04:37 +0100
parents 1424aa29ae95
children e802e550a1f2
comparison
equal deleted inserted replaced
809:0ef8a4bc48b9 810:b18f8c5fb4f5
35 #include <QRegExp> 35 #include <QRegExp>
36 #include <QTextStream> 36 #include <QTextStream>
37 37
38 #include "base/Thread.h" 38 #include "base/Thread.h"
39 39
40 //#define DEBUG_TRANSFORM_FACTORY 1
41
40 using std::cerr; 42 using std::cerr;
41 using std::endl; 43 using std::endl;
42 44
43 TransformFactory * 45 TransformFactory *
44 TransformFactory::m_instance = new TransformFactory; 46 TransformFactory::m_instance = new TransformFactory;
111 113
112 std::set<TransformDescription> dset; 114 std::set<TransformDescription> dset;
113 for (TransformDescriptionMap::const_iterator i = m_transforms.begin(); 115 for (TransformDescriptionMap::const_iterator i = m_transforms.begin();
114 i != m_transforms.end(); ++i) { 116 i != m_transforms.end(); ++i) {
115 #ifdef DEBUG_TRANSFORM_FACTORY 117 #ifdef DEBUG_TRANSFORM_FACTORY
116 SVDEBUG << "inserting transform into set: id = " << i->second.identifier << endl; 118 cerr << "inserting transform into set: id = " << i->second.identifier << endl;
117 #endif 119 #endif
118 dset.insert(i->second); 120 dset.insert(i->second);
119 } 121 }
120 122
121 TransformList list; 123 TransformList list;
122 for (std::set<TransformDescription>::const_iterator i = dset.begin(); 124 for (std::set<TransformDescription>::const_iterator i = dset.begin();
123 i != dset.end(); ++i) { 125 i != dset.end(); ++i) {
124 #ifdef DEBUG_TRANSFORM_FACTORY 126 #ifdef DEBUG_TRANSFORM_FACTORY
125 SVDEBUG << "inserting transform into list: id = " << i->identifier << endl; 127 cerr << "inserting transform into list: id = " << i->identifier << endl;
126 #endif 128 #endif
127 list.push_back(*i); 129 list.push_back(*i);
128 } 130 }
129 131
130 return list; 132 return list;
157 159
158 std::set<TransformDescription> dset; 160 std::set<TransformDescription> dset;
159 for (TransformDescriptionMap::const_iterator i = m_uninstalledTransforms.begin(); 161 for (TransformDescriptionMap::const_iterator i = m_uninstalledTransforms.begin();
160 i != m_uninstalledTransforms.end(); ++i) { 162 i != m_uninstalledTransforms.end(); ++i) {
161 #ifdef DEBUG_TRANSFORM_FACTORY 163 #ifdef DEBUG_TRANSFORM_FACTORY
162 SVDEBUG << "inserting transform into set: id = " << i->second.identifier << endl; 164 cerr << "inserting transform into set: id = " << i->second.identifier << endl;
163 #endif 165 #endif
164 dset.insert(i->second); 166 dset.insert(i->second);
165 } 167 }
166 168
167 TransformList list; 169 TransformList list;
168 for (std::set<TransformDescription>::const_iterator i = dset.begin(); 170 for (std::set<TransformDescription>::const_iterator i = dset.begin();
169 i != dset.end(); ++i) { 171 i != dset.end(); ++i) {
170 #ifdef DEBUG_TRANSFORM_FACTORY 172 #ifdef DEBUG_TRANSFORM_FACTORY
171 SVDEBUG << "inserting transform into uninstalled list: id = " << i->identifier << endl; 173 cerr << "inserting transform into uninstalled list: id = " << i->identifier << endl;
172 #endif 174 #endif
173 list.push_back(*i); 175 list.push_back(*i);
174 } 176 }
175 177
176 return list; 178 return list;
657 PluginRDFDescription desc(*i); 659 PluginRDFDescription desc(*i);
658 660
659 QString name = desc.getPluginName(); 661 QString name = desc.getPluginName();
660 #ifdef DEBUG_TRANSFORM_FACTORY 662 #ifdef DEBUG_TRANSFORM_FACTORY
661 if (name == "") { 663 if (name == "") {
662 SVDEBUG << "TransformFactory::populateUninstalledTransforms: " 664 cerr << "TransformFactory::populateUninstalledTransforms: "
663 << "No name available for plugin " << i- << ", skipping" << endl; 665 << "No name available for plugin " << *i
666 << ", skipping" << endl;
664 continue; 667 continue;
665 } 668 }
666 #endif 669 #endif
667 670
668 QString description = desc.getPluginDescription(); 671 QString description = desc.getPluginDescription();
675 678
676 TransformId tid = Transform::getIdentifierForPluginOutput(*i, *j); 679 TransformId tid = Transform::getIdentifierForPluginOutput(*i, *j);
677 680
678 if (m_transforms.find(tid) != m_transforms.end()) { 681 if (m_transforms.find(tid) != m_transforms.end()) {
679 #ifdef DEBUG_TRANSFORM_FACTORY 682 #ifdef DEBUG_TRANSFORM_FACTORY
680 SVDEBUG << "TransformFactory::populateUninstalledTransforms: " 683 cerr << "TransformFactory::populateUninstalledTransforms: "
681 << tid << " is installed; adding info url if appropriate, skipping rest" << endl; 684 << tid << " is installed; adding info url if appropriate, skipping rest" << endl;
682 #endif 685 #endif
683 if (infoUrl != "") { 686 if (infoUrl != "") {
684 if (m_transforms[tid].infoUrl == "") { 687 if (m_transforms[tid].infoUrl == "") {
685 m_transforms[tid].infoUrl = infoUrl; 688 m_transforms[tid].infoUrl = infoUrl;
687 } 690 }
688 continue; 691 continue;
689 } 692 }
690 693
691 #ifdef DEBUG_TRANSFORM_FACTORY 694 #ifdef DEBUG_TRANSFORM_FACTORY
692 SVDEBUG << "TransformFactory::populateUninstalledTransforms: " 695 cerr << "TransformFactory::populateUninstalledTransforms: "
693 << "adding " << tid << endl; 696 << "adding " << tid << endl;
694 #endif 697 #endif
695 698
696 QString oname = desc.getOutputName(*j); 699 QString oname = desc.getOutputName(*j);
697 if (oname == "") oname = *j; 700 if (oname == "") oname = *j;
950 plugin->getParameterDescriptors(); 953 plugin->getParameterDescriptors();
951 954
952 for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin(); 955 for (Vamp::PluginBase::ParameterList::const_iterator i = parameters.begin();
953 i != parameters.end(); ++i) { 956 i != parameters.end(); ++i) {
954 pmap[i->identifier.c_str()] = plugin->getParameter(i->identifier); 957 pmap[i->identifier.c_str()] = plugin->getParameter(i->identifier);
955 // SVDEBUG << "TransformFactory::setParametersFromPlugin: parameter " 958 // cerr << "TransformFactory::setParametersFromPlugin: parameter "
956 // << i->identifier << " -> value " << 959 // << i->identifier << " -> value " <<
957 // pmap[i->identifier.c_str()] << endl; 960 // pmap[i->identifier.c_str()] << endl;
958 } 961 }
959 962
960 transform.setParameters(pmap); 963 transform.setParameters(pmap);
1065 QString xml; 1068 QString xml;
1066 1069
1067 Vamp::PluginBase *plugin = instantiateDefaultPluginFor 1070 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
1068 (t.getIdentifier(), 0); 1071 (t.getIdentifier(), 0);
1069 if (!plugin) { 1072 if (!plugin) {
1070 SVDEBUG << "TransformFactory::getPluginConfigurationXml: " 1073 cerr << "TransformFactory::getPluginConfigurationXml: "
1071 << "Unable to instantiate plugin for transform \"" 1074 << "Unable to instantiate plugin for transform \""
1072 << t.getIdentifier() << "\"" << endl; 1075 << t.getIdentifier() << "\"" << endl;
1073 return xml; 1076 return xml;
1074 } 1077 }
1075 1078
1087 QString xml) 1090 QString xml)
1088 { 1091 {
1089 Vamp::PluginBase *plugin = instantiateDefaultPluginFor 1092 Vamp::PluginBase *plugin = instantiateDefaultPluginFor
1090 (t.getIdentifier(), 0); 1093 (t.getIdentifier(), 0);
1091 if (!plugin) { 1094 if (!plugin) {
1092 SVDEBUG << "TransformFactory::setParametersFromPluginConfigurationXml: " 1095 cerr << "TransformFactory::setParametersFromPluginConfigurationXml: "
1093 << "Unable to instantiate plugin for transform \"" 1096 << "Unable to instantiate plugin for transform \""
1094 << t.getIdentifier() << "\"" << endl; 1097 << t.getIdentifier() << "\"" << endl;
1095 return; 1098 return;
1096 } 1099 }
1097 1100
1143 } 1146 }
1144 1147
1145 if (!m_uninstalledTransformsMutex.tryLock()) { 1148 if (!m_uninstalledTransformsMutex.tryLock()) {
1146 // uninstalled transforms are being populated; this may take some time, 1149 // uninstalled transforms are being populated; this may take some time,
1147 // and they aren't critical, but we will speed them up if necessary 1150 // and they aren't critical, but we will speed them up if necessary
1148 SVDEBUG << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << endl; 1151 cerr << "TransformFactory::search: Uninstalled transforms mutex is held, skipping" << endl;
1149 m_populatingSlowly = false; 1152 m_populatingSlowly = false;
1150 return results; 1153 return results;
1151 } 1154 }
1152 1155
1153 if (!m_uninstalledTransformsPopulated) { 1156 if (!m_uninstalledTransformsPopulated) {