~ubuntu-branches/ubuntu/precise/lilypond/precise

« back to all changes in this revision

Viewing changes to lily/include/music-iterator.hh

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2006-12-19 10:18:12 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061219101812-7awtjkp0i393wxty
Tags: 2.8.7-3
scripts/midi2ly.py: When setting DATADIR, find Lilypond python files
in the @TOPLEVEL_VERSION@ directory, not 'current'.  Patch thanks to
Chris Lamb (chris@chris-lamb.co.uk).  (Closes: #400550)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
  source file of the GNU LilyPond music typesetter
5
5
 
6
 
  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
6
  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
7
*/
8
8
 
9
 
 
10
9
#ifndef MUSIC_ITERATOR_HH
11
10
#define MUSIC_ITERATOR_HH
12
11
 
13
 
#include "lily-proto.hh"
14
 
#include "array.hh"
 
12
#include "std-vector.hh"
15
13
#include "moment.hh"
16
14
#include "virtual-methods.hh"
17
 
#include "interpretation-context-handle.hh"
18
 
#include "smobs.hh"
 
15
#include "context-handle.hh"
19
16
 
20
17
/**
21
18
   ---
26
23
 
27
24
 
28
25
   ---
29
 
        
30
 
  Conceptually a music-iterator operates on a queue of musical events
31
 
  that are pending. This queue does not actually exist, but it is a
32
 
  way of viewing and traversing music-expressions.
33
 
 
34
 
  
35
 
  ok () -- events left ?
36
 
 
37
 
  pending_mom () -- time tag of the next event to be processed.
38
 
    PRECONDITION: this->ok () holds.
39
 
  
40
 
  process (M) -- process all at M (Precondition: no events exist
41
 
    before M, this->ok () holds).  Side-effects:
42
 
    
43
 
    * This removes all events at M from the pending queue.
44
 
 
45
 
    * Typically this reports the music to an interpretation context,
46
 
    thus changing the state of the interpretation context.
47
 
 
48
 
 
49
 
  TODO:
50
 
 
51
 
  merge pending_moment and process?
52
 
  
 
26
 
 
27
   Conceptually a music-iterator operates on a queue of musical events
 
28
   that are pending. This queue does not actually exist, but it is a
 
29
   way of viewing and traversing music-expressions.
 
30
 
 
31
 
 
32
   ok () -- events left ?
 
33
 
 
34
   pending_mom () -- time tag of the next event to be processed.
 
35
   PRECONDITION: this->ok () holds.
 
36
 
 
37
   process (M) -- process all at M (Precondition: no events exist
 
38
   before M, this->ok () holds).  Side-effects:
 
39
 
 
40
   * This removes all events at M from the pending queue.
 
41
 
 
42
   * Typically this reports the music to an interpretation context,
 
43
   thus changing the state of the interpretation context.
 
44
 
 
45
 
 
46
   TODO:
 
47
 
 
48
   merge pending_moment and process?
53
49
*/
54
50
class Music_iterator
55
51
{
57
53
  Moment music_length_;
58
54
  Moment start_mom_;
59
55
 
60
 
  DECLARE_SMOBS (Music_iterator,dummy);
61
 
  Music_iterator (Music_iterator const&);
 
56
  DECLARE_CLASSNAME(Music_iterator);
 
57
  DECLARE_SMOBS (Music_iterator, dummy);
 
58
  Music_iterator (Music_iterator const &);
 
59
 
62
60
public:
63
 
  
64
61
  Moment music_get_length () const;
65
 
  virtual Moment music_start_mom () const;
 
62
  Moment music_start_mom () const;
66
63
  Music_iterator ();
67
 
 
68
 
  /**
69
 
     Do the reporting.  Will try MUSIC_L_ in its own translator first,
70
 
     then its children. Returns the iterator that succeeded
71
 
  */
72
 
  Music_iterator *  try_music (Music  *) const;
73
 
  
74
 
  /**
75
 
    The translation unit that we this iterator is reporting  to now.
76
 
   */
77
 
  Context * get_outlet () const;
78
 
 
79
 
  void set_translator (Context *);
80
 
  
81
 
  /** Get an iterator matching the type of MUS, and use TRANS to find
82
 
    an accompanying translation unit
83
 
   */
84
 
  static SCM get_static_get_iterator (Music * mus);
85
 
  void init_translator (Music  *, Context *); 
 
64
  Music_iterator *try_music (Music *) const;
 
65
  Context *get_outlet () const;
 
66
  void set_context (Context *);
 
67
  static SCM get_static_get_iterator (Music *mus);
 
68
  void init_translator (Music *, Context *);
86
69
  void quit ();
87
 
  void substitute_outlet (Context * from, Context *to);
 
70
  void substitute_outlet (Context *from, Context *to);
88
71
  virtual void derived_substitute (Context *, Context *);
89
72
  virtual Moment pending_moment () const;
90
73
  virtual bool ok () const;
91
 
 
92
 
  virtual bool run_always () const; 
 
74
  virtual bool run_always () const;
93
75
  virtual void process (Moment until);
94
 
  virtual void derived_mark ()const;
 
76
  virtual void derived_mark () const;
95
77
  virtual void construct_children ();
96
 
  
97
 
  /**
98
 
    Construct sub-iterators, and set the translator to 
99
 
    report to.
100
 
   */
101
 
 
102
 
  DECLARE_SCHEME_CALLBACK(constructor, ());
103
 
  
104
 
  /**
105
 
    Get an iterator for MUS, inheriting the translation unit from THIS.
106
 
   */
 
78
  DECLARE_SCHEME_CALLBACK (constructor, ());
107
79
  SCM get_iterator (Music *) const;
108
80
 
109
 
  virtual Music_iterator* try_music_in_children (Music *) const;
 
81
  virtual Music_iterator *try_music_in_children (Music *) const;
110
82
 
111
 
  Music * get_music () const;
 
83
  Music *get_music () const;
112
84
protected:
113
 
  virtual void do_quit();
114
 
  void descend_to_child (Context*);
 
85
  virtual void do_quit ();
 
86
  void descend_to_child (Context *);
 
87
 
115
88
private:
116
 
  Interpretation_context_handle handle_;
117
 
  Music  * music_;
 
89
  Context_handle handle_;
 
90
  Music *music_;
118
91
};
119
92
 
120
93
bool is_child_context (Context *me, Context *child);
121
94
 
122
 
#define IMPLEMENT_CTOR_CALLBACK(Class)          \
123
 
LY_DEFINE_MEMBER_FUNCTION(Class,constructor, #Class "::constructor",\
124
 
          0,0,0,\
125
 
          (),\
126
 
          "")\
127
 
{                                               \
128
 
  SCM val = (new Class)->self_scm();   \
129
 
  scm_gc_unprotect_object (val);\
130
 
  return val ;                          \
131
 
}                                               \
 
95
#define IMPLEMENT_CTOR_CALLBACK(Class)                                  \
 
96
  LY_DEFINE_MEMBER_FUNCTION (Class, constructor, \
 
97
                             mangle_cxx_identifier (string (#Class) + "::constructor").c_str(), \
 
98
                             0, 0, 0,                                   \
 
99
                             (),                                        \
 
100
                             "")                                        \
 
101
  {                                                                     \
 
102
    Class *c = (new Class);                                             \
 
103
    return c->unprotect ();                                             \
 
104
  }
132
105
 
133
 
DECLARE_UNSMOB(Music_iterator, iterator);
 
106
DECLARE_UNSMOB (Music_iterator, iterator);
134
107
 
135
108
#endif // MUSIC_ITERATOR_HH