62#define GINAC_DECLARE_PRINT_CONTEXT_COMMON(classname) \
64 friend class function_options; \
65 friend class registered_class_options; \
66 static const GiNaC::print_context_class_info &get_class_info_static(); \
69#define GINAC_DECLARE_PRINT_CONTEXT_BASE(classname) \
70 GINAC_DECLARE_PRINT_CONTEXT_COMMON(classname) \
71 virtual const GiNaC::print_context_class_info &get_class_info() const { return classname::get_class_info_static(); } \
72 virtual const char *class_name() const { return classname::get_class_info_static().options.get_name(); } \
73 virtual classname * duplicate() const { return new classname(*this); } \
80#define GINAC_DECLARE_PRINT_CONTEXT(classname, supername) \
81 GINAC_DECLARE_PRINT_CONTEXT_COMMON(classname) \
82 typedef supername inherited; \
83 const GiNaC::print_context_class_info &get_class_info() const override { return classname::get_class_info_static(); } \
84 const char *class_name() const override { return classname::get_class_info_static().options.get_name(); } \
85 classname * duplicate() const override { return new classname(*this); } \
89#define GINAC_IMPLEMENT_PRINT_CONTEXT(classname, supername) \
90const GiNaC::print_context_class_info &classname::get_class_info_static() \
92 static GiNaC::print_context_class_info reg_info = GiNaC::print_context_class_info(GiNaC::print_context_options(#classname, #supername, GiNaC::next_print_context_id++)); \
190{
return dynamic_cast<const T *
>(&obj) !=
nullptr; }
204template <
class T,
class C>
207 typedef void (*
F)(
const T &,
const C &, unsigned);
215 f(
dynamic_cast<const T &
>(obj),
dynamic_cast<const C &
>(
c), level);
223template <
class T,
class C>
226 typedef void (T::*
F)(const C &
c, unsigned level) const;
234 return (
dynamic_cast<const T &
>(obj).*
f)(
dynamic_cast<const C &
>(
c), level);
253 template <
class T,
class C>
256 template <
class T,
class C>
261 if (
this != &other) {
263 impl.reset(p ? other.
impl->duplicate() :
nullptr);
270 (*impl)(obj,
c, level);
276 std::unique_ptr<print_functor_impl>
impl;
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
This class stores information about a registered print_context class.
const char * get_parent_name() const
const char * name
Class name.
const char * get_name() const
unsigned id
ID number (assigned automatically).
print_context_options(const char *n, const char *p, unsigned i)
const char * parent_name
Name of superclass.
Base class for print_contexts.
unsigned options
option flags
std::ostream & s
stream to output to
Context for C source output using CLN numbers.
Context for C source output using double precision.
Context for C source output using float precision.
Base context for C source output.
Context for default (ginsh-parsable) output.
Base class for print_functor handlers.
virtual ~print_functor_impl()
virtual print_functor_impl * duplicate() const =0
virtual void operator()(const basic &obj, const print_context &c, unsigned level) const =0
This class represents a print method for a certain algebraic class and print_context type.
print_functor(void f(const T &, const C &, unsigned))
print_functor(const print_functor &other)
void operator()(const basic &obj, const print_context &c, unsigned level) const
print_functor(void(T::*f)(const C &, unsigned) const)
std::unique_ptr< print_functor_impl > impl
print_functor(std::unique_ptr< print_functor_impl > impl_)
print_functor & operator=(const print_functor &other)
Context for latex-parsable output.
print_functor handler for member functions of class T, context type C
void(T::* F)(const C &c, unsigned level) const
print_memfun_handler * duplicate() const override
void operator()(const basic &obj, const print_context &c, unsigned level) const override
print_memfun_handler(F f_)
Flags to control the behavior of a print_context.
@ print_index_dimensions
print the dimensions of indices
print_functor handler for pointer-to-functions of class T, context type C
print_ptrfun_handler(F f_)
print_ptrfun_handler * duplicate() const override
void operator()(const basic &obj, const print_context &c, unsigned level) const override
void(* F)(const T &, const C &, unsigned)
Context for python-parsable output.
Context for python pretty-print output.
Context for tree-like output for debugging.
const unsigned delta_indent
size of indentation step
Helper templates to provide per-class information for class hierarchies.
unsigned next_print_context_id
Next free ID for print_context types.
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
class_info< print_context_options > print_context_class_info
#define GINAC_DECLARE_PRINT_CONTEXT_BASE(classname)
#define GINAC_DECLARE_PRINT_CONTEXT(classname, supername)
Macro for inclusion in the declaration of a print_context class.