void
Context_selector::register_context (Context *context)
{
- if (!contexts_)
- contexts_ = new Scheme_hash_table ();
int count = 0;
if (Context *first = retrieve_context (identify_context (context, 0)))
{
- count = robust_scm2int (first->get_property ("max"), 0);
+ count = robust_scm2int (first->get_property ("tweakCount"), 0);
count++;
SCM s = scm_int2num (count);
- first->set_property ("max", s);
- context->set_property ("count", s);
+ first->set_property ("tweakCount", s);
+ context->set_property ("tweakRank", s);
}
- /* FIXME: must alway set count, for get_property () not to segfault. */
- context->set_property ("count", scm_int2num (count));
- contexts_->set (identify_context (context, count), context->self_scm ());
+ /* FIXME: must alway set rank, for get_property () not to segfault. */
+ context->set_property ("tweakRank", scm_int2num (count));
+ store_context (identify_context (context, count), context);
}
SCM
Context_selector::identify_context (Context *context, int count)
{
/* TODO: start time, parent-context-at-start */
- return ly_symbol2scm ((context->context_name ()
- + ","
- + to_string (count)).to_str0 ());
+ return scm_list_3 (scm_makfrom0str (context->context_name ().to_str0 ()),
+ scm_makfrom0str (context->id_string ().to_str0 ()),
+ scm_int2num (count));
}
SCM
{
return
identify_context (context,
- robust_scm2int (context->get_property ("count"), 0));
+ robust_scm2int (context->get_property ("tweakRank"), 0));
+}
+
+void
+Context_selector::store_context (SCM context_id, Context *context)
+{
+ contexts_->set (ly_to_symbol (context_id), context->self_scm ());
}
Context *
-Context_selector::retrieve_context (SCM key)
+Context_selector::retrieve_context (SCM context_id)
{
- return unsmob_context (contexts_->get (key));
+ return unsmob_context (contexts_->get (ly_to_symbol (context_id)));
}
+
+void
+Context_selector::set_tweaks (SCM tweaks)
+{
+ (void) tweaks;
+ contexts_ = new Scheme_hash_table ();
+ //tweaks_ = tweaks;
+}
+