+// The Translator_creator class is only for translators defined in C.
+// Its elements are callable entities taking a context argument and
+// returning a corresponding translator.
+//
+// Other translator-creating entities may be alists and functions returning
+// such alists. Information for those, such as created grobs/properties
+// is attached via object properties.
+
+// Smob rather than Simple_smob since we want an entity for
+// property lookup.
+
+class Translator_creator : public Smob<Translator_creator>
+{
+ Translator_creator (Translator_creator const &); // don't define
+ Translator * (*allocate_)(Context *);
+ template <class T>
+ static Translator *allocate (Context *ctx);
+
+ Translator_creator (Translator * (*allocate)(Context *))
+ : allocate_(allocate)
+ {
+ smobify_self ();
+ }
+public:
+ // This is stupid, but constructors cannot have explicit template
+ // argument lists.
+ template <class T>
+ static Translator_creator *alloc()
+ {
+ return new Translator_creator(&allocate<T>);
+ }
+ SCM call (SCM ctx);
+ LY_DECLARE_SMOB_PROC (&Translator_creator::call, 1, 0, 0);
+};
+
+template <class T> Translator *
+Translator_creator::allocate (Context *ctx)
+{
+ return new T(ctx);
+}
+