Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | Related Pages

TScanVisitor.h

00001 /*
00002   Copyright © Grame 2003
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Lesser General Public
00006     License as published by the Free Software Foundation; either
00007     version 2.1 of the License, or (at your option) any later version.
00008     
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Lesser General Public License for more details.
00013     
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this library; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018     Grame Research Laboratory, 9, rue du Garet 69001 Lyon - France
00019     grame@grame.fr
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         // voices and corresponding notes count per staff
00093         map< long, map<long,long> >     fVoices;
00094         // staves and number of cue notes per staff
00095         map<long, long>     fCues;
00096         // staves and corresponding global index
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

Generated on Tue Mar 23 09:49:44 2004 for LibMusicXML by doxygen 1.3.3