00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __TScanVisitor__
00024 #define __TScanVisitor__
00025
00026 #include "exports.h"
00027 #include "bimap.h"
00028 #include "TRoutedVisitor.h"
00029 #include <map>
00030 #include <string>
00031
00032 using namespace std;
00033 using namespace MusicXML;
00034
00047 class VEXP TPartSummary : public smartable {
00048 public:
00049 VEXP friend SMARTP<TPartSummary> newPartSummary(string id);
00050
00052 const string getID () const { return fID; }
00053
00055 void setStaff (long staff, long index) { fIndexes[staff] = index; }
00057 long getStaffIndex (long staff) { return fIndexes[staff]; }
00059 long getStaff (long index) const;
00060
00062 void incCue (long staff) { fCues[staff] = fCues[staff] + 1; }
00064 void incVoice (long voice, long staff) { fVoices[voice][staff] = fVoices[voice][staff] + 1; }
00065
00067 long countStaves () const { return fIndexes.size(); }
00069 long countCueNotes (long staff) { return fCues[staff]; }
00071 long countVoices () const { return fVoices.size(); }
00073 long countVoices (long staff);
00075 long countVoiceNotes (long voice);
00077 long countStaffNotes (long staff);
00079 long countNotes (long voice, long staff) { return (fVoices[voice])[staff]; }
00080
00082 long getVoice (long index) const;
00084 long getMainStaff (long voice);
00085
00086 protected:
00087 TPartSummary(string id) : fID(id) {}
00088 ~TPartSummary() {}
00089
00090 private:
00091 string fID;
00092
00093 map< long, map<long,long> > fVoices;
00094
00095 map<long, long> fCues;
00096
00097 map<long, long> fIndexes;
00098 };
00099 typedef SMARTP<TPartSummary> SPartSummary;
00100
00104 class VEXP TScanVisitor : public TRoutedVisitor {
00105
00106 public:
00107 TScanVisitor() : fCurrentStaffIndex(0) {}
00108 virtual ~TScanVisitor() {}
00109
00110 VEXP friend SMARTP<TScanVisitor> newScanVisitor();
00111
00112 virtual void visite ( SNote& elt );
00113 virtual void visite ( SPWPart& elt );
00114
00115 long countParts() const { return fParts.size(); }
00116 map<string, SPartSummary>& summary() { return fParts; }
00117 const SPartSummary& getPartSummary(string partID) { return fParts[partID]; }
00118 const SPartSummary& current() const { return fCurrent; }
00119
00120 private:
00121 long fCurrentStaffIndex;
00122 map<string, SPartSummary> fParts;
00123 SPartSummary fCurrent;
00124 };
00125 typedef SMARTP<TScanVisitor> SScanVisitor;
00126
00130 #endif