* The grand 2005-2006 replace.
[lilypond/patrick.git] / lily / include / object-key.hh
blob8cd5803d30b2114f622376454248d86a32b22c3c
1 /*
2 object-key.hh -- declare Object_key
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #ifndef OBJECT_KEY_HH
10 #define OBJECT_KEY_HH
12 #include "smobs.hh"
15 Object_keys are read-only values, suitable for storing references to
16 transient objects (such as grobs or contexts) on disk.
18 In the future, they might also act as handles for external processes
19 requesting notation to be drawn.
21 class Object_key
23 DECLARE_SMOBS (Object_key,);
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 virtual SCM as_scheme () const;
31 public:
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;
38 enum Object_key_type
40 BASE_KEY,
41 COPIED_KEY,
42 GENERAL_KEY,
43 GROB_KEY,
44 CONTEXT_KEY,
45 KEY_COUNT,
48 class Copied_key : public Object_key
51 private:
52 Object_key const *original_;
53 int copy_count_;
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);
65 DECLARE_UNSMOB (Object_key, key);
67 struct Object_key_less
69 bool operator () (Object_key const *const &t1, Object_key const *const &t2) const
71 return t1->compare (t2);
75 #endif /* OBJECT_KEY_HH */