23#ifndef GINAC_REGISTRAR_H
24#define GINAC_REGISTRAR_H
39template <
template <
class T,
class = std::allocator<T>>
class>
class container;
40typedef container<std::list>
lst;
63 return rl == other.
rl;
75 ret.
tinfo = &
typeid(T);
83 const std::type_info& ti)
91 template <
class Ctx,
class T,
class C>
98 template <
class Ctx,
class T,
class C>
129#define GINAC_DECLARE_REGISTERED_CLASS_COMMON(classname) \
131 static GiNaC::registered_class_info reg_info; \
133 static GiNaC::registered_class_info &get_class_info_static() { return reg_info; } \
136 virtual void visit(const classname &) = 0; \
137 virtual ~visitor() {}; \
141#define GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername) \
142 GINAC_DECLARE_REGISTERED_CLASS_COMMON(classname) \
143 typedef supername inherited; \
144 virtual const GiNaC::registered_class_info &get_class_info() const { return classname::get_class_info_static(); } \
145 virtual GiNaC::registered_class_info &get_class_info() { return classname::get_class_info_static(); } \
146 virtual const char *class_name() const { return classname::get_class_info_static().options.get_name(); } \
153#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername) \
154 GINAC_DECLARE_REGISTERED_CLASS_COMMON(classname) \
155 template<class B, typename... Args> friend B & dynallocate(Args &&... args); \
156 typedef supername inherited; \
158 classname * duplicate() const override { \
159 classname * bp = new classname(*this); \
160 bp->setflag(GiNaC::status_flags::dynallocated); \
164 void accept(GiNaC::visitor & v) const override \
166 if (visitor *p = dynamic_cast<visitor *>(&v)) \
169 inherited::accept(v); \
171 const GiNaC::registered_class_info &get_class_info() const override { return classname::get_class_info_static(); } \
172 GiNaC::registered_class_info &get_class_info() override { return classname::get_class_info_static(); } \
173 const char *class_name() const override { return classname::get_class_info_static().options.get_name(); } \
175 int compare_same_type(const GiNaC::basic & other) const override; \
180#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername) \
181 GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, typeid(classname)));
185#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(classname, supername, options) \
186 GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, typeid(classname)).options);
190#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(classname, supername, options) \
191 GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, typeid(classname)).options);
195template <
class Alg,
class Ctx,
class T,
class C>
198 Alg::get_class_info_static().options.set_print_func(Ctx::get_class_info_static().
options.get_id(), f);
202template <
class Alg,
class Ctx,
class T,
class C>
205 Alg::get_class_info_static().options.set_print_func(Ctx::get_class_info_static().
options.get_id(), f);
This class represents a print method for a certain algebraic class and print_context type.
This class stores information about a registered GiNaC class.
const char * name
Class name.
const std::vector< print_functor > & get_print_dispatch_table() const
std::type_info const * tinfo_key
Type information key.
const char * get_parent_name() const
registered_class_options(const char *n, const char *p, const std::type_info &ti)
registered_class_options & print_func(void f(const T &, const C &c, unsigned))
const char * parent_name
Name of superclass.
registered_class_options & print_func(void(T::*f)(const C &, unsigned))
registered_class_options & print_func(const print_functor &f)
const char * get_name() const
void set_print_func(unsigned id, const print_functor &f)
std::vector< print_functor > print_dispatch_table
Method table for print() dispatch.
std::type_info const * get_id() const
Helper templates to provide per-class information for class hierarchies.
container< std::list > lst
class_info< registered_class_options > registered_class_info
return_type_t make_return_type_t(const unsigned rl=0)
void set_print_func(void f(const T &, const C &c, unsigned))
Add or replace a print method.
Definition of helper classes for expression output.
To distinguish between different kinds of non-commutative objects.
std::type_info const * tinfo
to distinguish between non-commutative objects of different type.
bool operator!=(const return_type_t &other) const
bool operator==(const return_type_t &other) const
unsigned rl
to distinguish between non-commutative objects of the same type.
bool operator<(const return_type_t &other) const
Strict weak ordering (so one can put return_type_t's into a STL container).