LibMusicXML  3.18
partsummary.h
1 /*
2  MusicXML Library
3  Copyright (C) Grame 2006-2013
4 
5  This Source Code Form is subject to the terms of the Mozilla Public
6  License, v. 2.0. If a copy of the MPL was not distributed with this
7  file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10  research@grame.fr
11 */
12 
13 #ifndef __partsummary__
14 #define __partsummary__
15 
16 #include <map>
17 #include <vector>
18 
19 #include "notevisitor.h"
20 #include "smartlist.h"
21 
22 namespace MusicXML2
23 {
24 
38 class EXP partsummary :
39  public notevisitor,
40  public visitor<S_part>,
41  public visitor<S_staves>,
42  public visitor<S_print>
43 {
44  public:
45  partsummary() : fStavesCount(1) {};
46  virtual ~partsummary() {};
47 
49  int countStaves () const { return fStavesCount; }
51  int countVoices () const { return int(fVoices.size()); }
53  int countVoices (int staff) const;
54 
58  smartlist<int>::ptr getStaves (int voice) const;
60  int getStaffNotes (int id) const;
61 
65  smartlist<int>::ptr getVoices (int staff) const;
67  int getMainStaff (int voiceid) const;
69  int getVoiceNotes (int voiceid) const;
71  int getVoiceNotes (int staffid, int voiceid) const;
72  // staff distance from S_print
73  std::map<int, int> fStaffDistances;
74 
75  protected:
76  virtual void visitStart ( S_part& elt);
77  virtual void visitStart ( S_staves& elt);
78  virtual void visitStart ( S_print& elt);
79  virtual void visitEnd ( S_note& elt);
80 
81  private:
82  // count of staves (from the staves element)
83  int fStavesCount;
84  // staves and corresponding count of notes
85  std::map<int, int> fStaves;
86  // voices and corresponding count of notes
87  std::map<int, int> fVoices;
88  // staves and corresponding voices + count of notes
89  std::map<int, std::map<int, int> > fStaffVoices;
90 
91 };
92 
95 }
96 
97 #endif
MusicXML2::partsummary::getVoices
smartlist< int >::ptr getVoices() const
returns the voices ids list
MusicXML2::partsummary::getVoiceNotes
int getVoiceNotes(int voiceid) const
returns the count of notes on a voice
MusicXML2::notevisitor
A note visitor.
Definition: notevisitor.h:86
MusicXML2::partsummary::countVoices
int countVoices(int staff) const
returns the number of voices on a staff
MusicXML2::partsummary::countStaves
int countStaves() const
returns the number of staves for the part
Definition: partsummary.h:49
MusicXML2::partsummary::getStaffNotes
int getStaffNotes(int id) const
returns the count of notes on a staff
MusicXML2::partsummary::getVoices
smartlist< int >::ptr getVoices(int staff) const
returns the voices ids list for one staff
MusicXML2::partsummary::getVoiceNotes
int getVoiceNotes(int staffid, int voiceid) const
returns the count of notes on a voice and a staff
MusicXML2::partsummary
Produces a summary of a MusicXML part.
Definition: partsummary.h:43
MusicXML2::partsummary::getStaves
smartlist< int >::ptr getStaves() const
returns the staff ids list
MusicXML2::SMARTP
the smart pointer implementation
Definition: smartpointer.h:58
MusicXML2::visitor
Definition: visitor.h:27
MusicXML2::partsummary::getMainStaff
int getMainStaff(int voiceid) const
returns the id of the staff that contains the more of the voice notes
MusicXML2::partsummary::getStaves
smartlist< int >::ptr getStaves(int voice) const
returns the staff ids list for one voice
MusicXML2::partsummary::countVoices
int countVoices() const
returns the number of voices
Definition: partsummary.h:51