]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/object-key.hh
Merge branch 'jneeman' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond into jneeman
[lilypond.git] / lily / include / object-key.hh
1 /*
2   object-key.hh -- declare Object_key
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef OBJECT_KEY_HH
10 #define OBJECT_KEY_HH
11
12 #include "smobs.hh"
13
14 /*
15   Object_keys are read-only values, suitable for storing references to
16   transient objects (such as grobs or contexts) on disk.
17
18   In the future, they might also act as handles for external processes
19   requesting notation to be drawn.
20 */
21 class Object_key
22 {
23   DECLARE_SMOBS (Object_key);
24
25 protected:
26   Object_key ();
27   virtual void derived_mark () const;
28   virtual int get_type () const;
29   virtual int do_compare (Object_key const *other) const;
30 public:
31   virtual SCM as_scheme () const;
32   static Object_key *from_scheme (SCM);
33   static Object_key *undump (SCM);
34   int compare (Object_key const *other) const;
35   SCM dump () const;
36 };
37
38 enum Object_key_type
39   {
40     BASE_KEY,
41     COPIED_KEY,
42     GENERAL_KEY,
43     GROB_KEY,
44     CONTEXT_KEY,
45     KEY_COUNT,
46   };
47
48 class Copied_key : public Object_key
49 {
50
51 private:
52   Object_key const *original_;
53   int copy_count_;
54
55 protected:
56   virtual void derived_mark () const;
57   virtual int get_type () const;
58   virtual int do_compare (Object_key const *other) const;
59   virtual SCM as_scheme () const;
60 public:
61   static Object_key *from_scheme (SCM);
62   Copied_key (Object_key const *, int);
63 };
64
65 DECLARE_UNSMOB (Object_key, key);
66
67 struct Object_key_less
68 {
69   bool operator () (Object_key const *const &t1, Object_key const *const &t2) const
70   {
71     return t1->compare (t2);
72   }
73 };
74
75 #endif /* OBJECT_KEY_HH */