[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
engraver question: how to define an array to store events?
From: |
Marc Hohl |
Subject: |
engraver question: how to define an array to store events? |
Date: |
Tue, 20 Sep 2011 08:59:32 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 |
Hello list,
while trying to get more insight into the engraver stuff, I encountered a
problem. I hope I can explain it:
I need some kind of a array of vectors:
vector<Stream_event*> slot_[max];
where I can store events later on by calling
slot_[i].push_back (event);
The index i lies in a fixed range from 0 to some value max, but it
isn't processed sequentially, so the calculations could start with i=4,
then comes i=0 etc.
As far as I understand c++, I cannot access i=4 directly if i=0...3
weren't accessed before.
So I tried to initialize the vector within initialize () as follows:
void
My_engraver::initialize ()
{
static int const max = 12;
vector<Stream_event*> slot_[max];
for (int i = 0; i < max; i++)
slot_[i] = 0;
};
but then slot_[] and max are not accessible in process_music ();
When I move the declarations to
class My_engraver : public Engraver
{
.
.
.
private:
static int const max = 12;
vector<Stream_event*> slot_[max];
.
.
.
}
void
My_engraver::initialize ()
{
for (int i = 0; i < max; i++)
slot_[i] = 0;
};
then I got
error: no match for 'operator=' in
'((My_engraver*)this)-My_engraver::slot_[i] = 0'
How can this be solved? Or is there a better approach to store events in
an array
the way I described above?
Thanks in advance!
Marc
- engraver question: how to define an array to store events?,
Marc Hohl <=