63#define GINAC_DECLARE_PRINT_CONTEXT_COMMON(classname) \
65 friend class function_options; \
66 friend class registered_class_options; \
67 static const GiNaC::print_context_class_info &get_class_info_static(); \
70#define GINAC_DECLARE_PRINT_CONTEXT_BASE(classname) \
71 GINAC_DECLARE_PRINT_CONTEXT_COMMON(classname) \
72 virtual const GiNaC::print_context_class_info &get_class_info() const { return classname::get_class_info_static(); } \
73 virtual const char *class_name() const { return classname::get_class_info_static().options.get_name(); } \
74 virtual classname * duplicate() const { return new classname(*this); } \
81#define GINAC_DECLARE_PRINT_CONTEXT(classname, supername) \
82 GINAC_DECLARE_PRINT_CONTEXT_COMMON(classname) \
83 typedef supername inherited; \
84 const GiNaC::print_context_class_info &get_class_info() const override { return classname::get_class_info_static(); } \
85 const char *class_name() const override { return classname::get_class_info_static().options.get_name(); } \
86 classname * duplicate() const override { return new classname(*this); } \
90#define GINAC_IMPLEMENT_PRINT_CONTEXT(classname, supername) \
91const GiNaC::print_context_class_info &classname::get_class_info_static() \
93 static GiNaC::print_context_class_info reg_info = GiNaC::print_context_class_info(GiNaC::print_context_options(#classname, #supername, GiNaC::next_print_context_id++)); \
191{
return dynamic_cast<const T *
>(&obj) !=
nullptr; }
205template <
class T,
class C>
208 typedef void (*
F)(
const T &,
const C &, unsigned);
216 f(
dynamic_cast<const T &
>(obj),
dynamic_cast<const C &
>(
c), level);
224template <
class T,
class C>
227 typedef void (T::*
F)(
const C &
c,
unsigned level)
const;
235 return (
dynamic_cast<const T &
>(obj).*
f)(
dynamic_cast<const C &
>(
c), level);
254 template <
class T,
class C>
257 template <
class T,
class C>
262 if (
this != &other) {
264 impl.reset(p ? other.
impl->duplicate() :
nullptr);
271 (*impl)(obj,
c, level);
277 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.
print_context(std::ostream &, unsigned options=0)
unsigned options
option flags
std::ostream & s
stream to output to
Context for C source output using CLN numbers.
print_csrc_cl_N(std::ostream &, unsigned options=0)
Context for C source output using double precision.
print_csrc_double(std::ostream &, unsigned options=0)
Context for C source output using float precision.
print_csrc_float(std::ostream &, unsigned options=0)
Base context for C source output.
print_csrc(std::ostream &, unsigned options=0)
Context for default (ginsh-parsable) output.
print_dflt(std::ostream &, unsigned options=0)
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_latex(std::ostream &, unsigned options=0)
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.
print_python_repr(std::ostream &, unsigned options=0)
Context for python pretty-print output.
print_python(std::ostream &, unsigned options=0)
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.