]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob-properties.hh
157613debb6ac98de676fbba8ee9eed6a09b2cce
[lilypond.git] / lily / include / grob-properties.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2014 David Kastrup <dak@gnu.org>
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 // This module is concerned with managing grob-properties (more
21 // exactly, grob property templates, as they are not yet part of a
22 // grob) inside of context properties, in a context-hierarchical
23 // manner, with one stack for properties and subproperties per
24 // context.
25
26 #ifndef GROB_PROPERTIES_HH
27 #define GROB_PROPERTIES_HH
28
29 #include "lily-proto.hh"
30
31 // Several algorithms on Grob_properties need self-identifying
32 // information to work properly, but there is no point in storing them
33 // in the Grob_properties data structure itself.  Instead we create a
34 // reflective data structure containing all necessary information for
35 // the algorithms processing Grob_properties.
36
37 class Grob_property_info {
38   Context * const context_;
39   SCM const symbol_;
40   Grob_properties *props_;
41 public:
42   Grob_property_info (Context *context, SCM symbol, Grob_properties *props = 0)
43     : context_ (context), symbol_ (symbol), props_ (props)
44   { }
45   operator bool () { return props_; }
46   Grob_property_info find ();
47   bool check ();
48   bool create ();
49   SCM updated ();
50   SCM push (SCM path, SCM value);
51   void matched_pop (SCM);
52   void pop (SCM path);
53   void pushpop (SCM path, SCM value)
54   {
55     if (SCM_UNBNDP (value))
56       return pop (path);
57     push (path, value);
58   }
59 };
60 #endif