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
22namespace MusicXML2
23{
24
38class 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
the smart pointer implementation
Definition: smartpointer.h:58
A note visitor.
Definition: notevisitor.h:86
Produces a summary of a MusicXML part.
Definition: partsummary.h:43
smartlist< int >::ptr getVoices() const
returns the voices ids list
int getVoiceNotes(int voiceid) const
returns the count of notes on a voice
int getMainStaff(int voiceid) const
returns the id of the staff that contains the more of the voice notes
smartlist< int >::ptr getStaves() const
returns the staff ids list
int countVoices(int staff) const
returns the number of voices on a staff
int countVoices() const
returns the number of voices
Definition: partsummary.h:51
smartlist< int >::ptr getVoices(int staff) const
returns the voices ids list for one staff
int countStaves() const
returns the number of staves for the part
Definition: partsummary.h:49
int getStaffNotes(int id) const
returns the count of notes on a staff
smartlist< int >::ptr getStaves(int voice) const
returns the staff ids list for one voice
int getVoiceNotes(int staffid, int voiceid) const
returns the count of notes on a voice and a staff
Definition: visitor.h:27