]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob-array.hh
c21fc3cf502e285c901e067801776521d694850f
[lilypond.git] / lily / include / grob-array.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GROB_ARRAY_HH
21 #define GROB_ARRAY_HH
22
23 #include "lily-proto.hh"
24 #include "smobs.hh"
25 #include "std-vector.hh"
26
27 class Grob_array
28 {
29   vector<Grob *> grobs_;
30   bool ordered_;
31
32   DECLARE_SIMPLE_SMOBS (Grob_array);
33
34   Grob_array ();
35 public:
36   bool ordered () const { return ordered_; }
37   void set_ordered (bool b) { ordered_ = b; }
38   Item *item (vsize i);
39   Spanner *spanner (vsize i);
40   Grob *grob (vsize i) { return grobs_.at (i); }
41   vsize size () const { return grobs_.size (); }
42   bool empty () const;
43   void remove_duplicates ();
44   void clear ();
45   void add (Grob *x) { grobs_.push_back (x); }
46   void set_array (vector<Grob *> const &src);
47   vector<Grob *> &array_reference ();
48   vector<Grob *> const &array () const;
49   static SCM make_array ();
50 };
51
52 DECLARE_UNSMOB (Grob_array, grob_array);
53
54 vector<Grob *> const &ly_scm2link_array (SCM x);
55 SCM grob_list_to_grob_array (SCM lst);
56 SCM grob_array_to_list (Grob_array *array);
57
58 #endif /* GROB_ARRAY_HH */
59