2 context-key-manager.cc -- implement Context_key_manager
4 source file of the GNU LilyPond music typesetter
6 (c) 2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "context-key-manager.hh"
11 #include "object-key.hh"
12 #include "lilypond-key.hh"
15 Context_key_manager::Context_key_manager (Object_key const *key)
21 Context_key_manager::unprotect () const
24 ((Object_key *)key_)->unprotect ();
29 Context_key_manager::get_context_key (Moment now, string type, string id)
34 string now_key = type + "@" + id;
36 int disambiguation_count = 0;
37 if (context_counts_.find (now_key) != context_counts_.end ())
38 disambiguation_count = context_counts_[now_key];
40 context_counts_[now_key] = disambiguation_count + 1;
42 return new Lilypond_context_key (key (),
45 disambiguation_count);
50 Context_key_manager::get_grob_key (Moment m, string name)
55 return create_grob_key (m, name);
59 We want to have a key for some objects anyway, so we can invent a
60 unique identifier for each (book,score) tuple.
63 Context_key_manager::create_grob_key (Moment now, string name)
65 int disambiguation_count = 0;
66 if (grob_counts_.find (name) != grob_counts_.end ())
67 disambiguation_count = grob_counts_[name];
68 grob_counts_[name] = disambiguation_count + 1;
70 Object_key *k = new Lilypond_grob_key (key (),
73 disambiguation_count);
79 Context_key_manager::gc_mark () const
82 scm_gc_mark (key_->self_scm ());
87 Context_key_manager::clear ()
92 grob_counts_.clear ();
93 context_counts_.clear ();
96 Context_key_manager::Context_key_manager (Context_key_manager const &src)