-/** This structure stores information about a registered GiNaC class. */
-struct registered_class_info {
- registered_class_info(const char *n, const char *s, unsigned int k, unarch_func f)
- : name(n), super(s), tinfo_key(k), unarchive(f)
- {
- // Add structure to list
- next = first_registered_class;
- first_registered_class = this;
- }
+template<typename T> inline return_type_t make_return_type_t(const unsigned rl = 0)
+{
+ return_type_t ret;
+ ret.rl = rl;
+ ret.tinfo = &typeid(T);
+ return ret;
+}
+
+/** This class stores information about a registered GiNaC class. */
+class registered_class_options {
+public:
+ registered_class_options(const char *n, const char *p,
+ const std::type_info& ti)
+ : name(n), parent_name(p), tinfo_key(&ti) { }
+
+ const char *get_name() const { return name; }
+ const char *get_parent_name() const { return parent_name; }
+ std::type_info const* get_id() const { return tinfo_key; }
+ const std::vector<print_functor> &get_print_dispatch_table() const { return print_dispatch_table; }
+
+ template <class Ctx, class T, class C>
+ registered_class_options & print_func(void f(const T &, const C & c, unsigned))
+ {
+ set_print_func(Ctx::get_class_info_static().options.get_id(), f);
+ return *this;
+ }
+
+ template <class Ctx, class T, class C>
+ registered_class_options & print_func(void (T::*f)(const C &, unsigned))
+ {
+ set_print_func(Ctx::get_class_info_static().options.get_id(), f);
+ return *this;
+ }
+
+ template <class Ctx>
+ registered_class_options & print_func(const print_functor & f)
+ {
+ set_print_func(Ctx::get_class_info_static().options.get_id(), f);
+ return *this;
+ }
+
+ void set_print_func(unsigned id, const print_functor & f)
+ {
+ if (id >= print_dispatch_table.size())
+ print_dispatch_table.resize(id + 1);
+ print_dispatch_table[id] = f;
+ }