comparison rdf/RDFFeatureWriter.cpp @ 689:573d45e9487b

Merge from debug-output branch
author Chris Cannam
date Tue, 14 Jun 2011 14:47:59 +0100
parents 06f13a3b9e9e
children 1424aa29ae95
comparison
equal deleted inserted replaced
688:be43b2fe68e8 689:573d45e9487b
110 110
111 void 111 void
112 RDFFeatureWriter::setTrackMetadata(QString trackId, 112 RDFFeatureWriter::setTrackMetadata(QString trackId,
113 TrackMetadata metadata) 113 TrackMetadata metadata)
114 { 114 {
115 // cerr << "setTrackMetadata: title = " << metadata.title.toStdString() << ", maker = " << metadata.maker.toStdString() << endl; 115 // cerr << "setTrackMetadata: title = " << metadata.title << ", maker = " << metadata.maker << endl;
116 m_metadata[trackId] = metadata; 116 m_metadata[trackId] = metadata;
117 } 117 }
118 118
119 void 119 void
120 RDFFeatureWriter::setFixedEventTypeURI(QString uri) 120 RDFFeatureWriter::setFixedEventTypeURI(QString uri)
139 } 139 }
140 140
141 m_rdfDescriptions[pluginId] = PluginRDFDescription(pluginId); 141 m_rdfDescriptions[pluginId] = PluginRDFDescription(pluginId);
142 142
143 if (m_rdfDescriptions[pluginId].haveDescription()) { 143 if (m_rdfDescriptions[pluginId].haveDescription()) {
144 cerr << "NOTE: Have RDF description for plugin ID \"" 144 DEBUG << "NOTE: Have RDF description for plugin ID \""
145 << pluginId.toStdString() << "\"" << endl; 145 << pluginId << "\"" << endl;
146 } else { 146 } else {
147 cerr << "NOTE: No RDF description for plugin ID \"" 147 DEBUG << "NOTE: No RDF description for plugin ID \""
148 << pluginId.toStdString() << "\"" << endl; 148 << pluginId << "\"" << endl;
149 if (!m_network) { 149 if (!m_network) {
150 cerr << " Consider using the --rdf-network option to retrieve plugin descriptions" << endl; 150 cerr << " Consider using the --rdf-network option to retrieve plugin descriptions" << endl;
151 cerr << " from the network where possible." << endl; 151 cerr << " from the network where possible." << endl;
152 } 152 }
153 } 153 }
260 // Appending to an RDF file is tricky, because we need to ensure 260 // Appending to an RDF file is tricky, because we need to ensure
261 // that our URIs differ from any already in the file. This is a 261 // that our URIs differ from any already in the file. This is a
262 // dirty grubby low-rent way of doing that. This function is 262 // dirty grubby low-rent way of doing that. This function is
263 // called by FileFeatureWriter::getOutputFile when in append mode. 263 // called by FileFeatureWriter::getOutputFile when in append mode.
264 264
265 // std::cerr << "reviewFileForAppending(" << filename.toStdString() << ")" << std::endl; 265 // std::cerr << "reviewFileForAppending(" << filename << ")" << std::endl;
266 266
267 QFile file(filename); 267 QFile file(filename);
268 268
269 // just return, don't report failure -- function that called us will do that 269 // just return, don't report failure -- function that called us will do that
270 if (!file.open(QIODevice::ReadOnly)) return; 270 if (!file.open(QIODevice::ReadOnly)) return;
290 290
291 void 291 void
292 RDFFeatureWriter::writeSignalDescription(QTextStream *sptr, 292 RDFFeatureWriter::writeSignalDescription(QTextStream *sptr,
293 QString trackId) 293 QString trackId)
294 { 294 {
295 // std::cerr << "RDFFeatureWriter::writeSignalDescription" << std::endl; 295 // DEBUG << "RDFFeatureWriter::writeSignalDescription" << endl;
296 296
297 QTextStream &stream = *sptr; 297 QTextStream &stream = *sptr;
298 298
299 /* 299 /*
300 * Describe signal we're analysing (AudioFile, Signal, TimeLine, etc.) 300 * Describe signal we're analysing (AudioFile, Signal, TimeLine, etc.)
346 bool wantTrack = (userSpecifiedTrack || 346 bool wantTrack = (userSpecifiedTrack ||
347 (m_userMakerUri != "") || 347 (m_userMakerUri != "") ||
348 (m_metadata.find(trackId) != m_metadata.end())); 348 (m_metadata.find(trackId) != m_metadata.end()));
349 349
350 // cerr << "wantTrack = " << wantTrack << " (userSpecifiedTrack = " 350 // cerr << "wantTrack = " << wantTrack << " (userSpecifiedTrack = "
351 // << userSpecifiedTrack << ", m_userMakerUri = " << m_userMakerUri.toStdString() << ", have metadata = " << (m_metadata.find(trackId) != m_metadata.end()) << ")" << endl; 351 // << userSpecifiedTrack << ", m_userMakerUri = " << m_userMakerUri << ", have metadata = " << (m_metadata.find(trackId) != m_metadata.end()) << ")" << endl;
352 352
353 if (wantTrack) { 353 if (wantTrack) {
354 // We only write a Track at all if we have some title/artist 354 // We only write a Track at all if we have some title/artist
355 // metadata to put in it, or if the user has requested a 355 // metadata to put in it, or if the user has requested a
356 // specific track URI. Otherwise we can't be sure that what 356 // specific track URI. Otherwise we can't be sure that what
518 const Plugin::OutputDescriptor& od, 518 const Plugin::OutputDescriptor& od,
519 const Plugin::FeatureList& featureList, 519 const Plugin::FeatureList& featureList,
520 PluginRDFDescription &desc, 520 PluginRDFDescription &desc,
521 QString timelineURI) 521 QString timelineURI)
522 { 522 {
523 // std::cerr << "RDFFeatureWriter::writeSparseRDF: have " << featureList.size() << " features" << std::endl; 523 // DEBUG << "RDFFeatureWriter::writeSparseRDF: have " << featureList.size() << " features" << endl;
524 524
525 if (featureList.empty()) return; 525 if (featureList.empty()) return;
526 QTextStream &stream = *sptr; 526 QTextStream &stream = *sptr;
527 527
528 bool plain = (m_plain || !desc.haveDescription()); 528 bool plain = (m_plain || !desc.haveDescription());
619 619
620 QString outputId = od.identifier.c_str(); 620 QString outputId = od.identifier.c_str();
621 QString featureUri = desc.getOutputFeatureAttributeURI(outputId); 621 QString featureUri = desc.getOutputFeatureAttributeURI(outputId);
622 622
623 if (featureUri == "") { 623 if (featureUri == "") {
624 cerr << "RDFFeatureWriter::writeTrackLevelRDF: ERROR: No feature URI available -- this function should not have been called!" << endl; 624 DEBUG << "RDFFeatureWriter::writeTrackLevelRDF: ERROR: No feature URI available -- this function should not have been called!" << endl;
625 return; 625 return;
626 } 626 }
627 627
628 for (int i = 0; i < featureList.size(); ++i) { 628 for (int i = 0; i < featureList.size(); ++i) {
629 629
763 } 763 }
764 } 764 }
765 765
766 void RDFFeatureWriter::finish() 766 void RDFFeatureWriter::finish()
767 { 767 {
768 // cerr << "RDFFeatureWriter::finish()" << endl; 768 // DEBUG << "RDFFeatureWriter::finish()" << endl;
769 769
770 // close any open dense feature literals 770 // close any open dense feature literals
771 771
772 for (map<StringTransformPair, StreamBuffer>::iterator i = 772 for (map<StringTransformPair, StreamBuffer>::iterator i =
773 m_openDenseFeatures.begin(); 773 m_openDenseFeatures.begin();
774 i != m_openDenseFeatures.end(); ++i) { 774 i != m_openDenseFeatures.end(); ++i) {
775 // cerr << "closing a stream" << endl; 775 // DEBUG << "closing a stream" << endl;
776 StreamBuffer &b = i->second; 776 StreamBuffer &b = i->second;
777 *(b.first) << b.second << "\" ." << endl; 777 *(b.first) << b.second << "\" ." << endl;
778 } 778 }
779 779
780 m_openDenseFeatures.clear(); 780 m_openDenseFeatures.clear();