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) \ 91 const 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; }
205 template <
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);
224 template <
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;
283 #endif // ndef GINAC_BASIC_H
unsigned next_print_context_id
Next free ID for print_context types.
print_csrc(std::ostream &, unsigned options=0)
print_csrc_double(std::ostream &, unsigned options=0)
Helper templates to provide per-class information for class hierarchies.
unsigned id
ID number (assigned automatically).
Base class for print_functor handlers.
print_functor(void(T::*f)(const C &, unsigned) const)
#define GINAC_DECLARE_PRINT_CONTEXT_BASE(classname)
const unsigned delta_indent
size of indentation step
Context for C source output using float precision.
print the dimensions of indices
Context for C source output using double precision.
const char * parent_name
Name of superclass.
print_dflt(std::ostream &, unsigned options=0)
print_memfun_handler(F f_)
print_context(std::ostream &, unsigned options=0)
print_csrc_float(std::ostream &, unsigned options=0)
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Context for python-parsable output.
print_csrc_cl_N(std::ostream &, unsigned options=0)
print_latex(std::ostream &, unsigned options=0)
const char * get_parent_name() const
print_context_options(const char *n, const char *p, unsigned i)
Flags to control the behavior of a print_context.
print_memfun_handler * duplicate() const override
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
Context for python pretty-print output.
print_functor(std::unique_ptr< print_functor_impl > impl_)
Context for default (ginsh-parsable) output.
virtual void operator()(const basic &obj, const print_context &c, unsigned level) const =0
Context for latex-parsable output.
print_ptrfun_handler(F f_)
class_info< print_context_options > print_context_class_info
const char * name
Class name.
print_functor & operator=(const print_functor &other)
virtual print_functor_impl * duplicate() const =0
print_ptrfun_handler * duplicate() const override
print_functor(const print_functor &other)
print_python_repr(std::ostream &, unsigned options=0)
void(T::* F)(const C &c, unsigned level) const
print_functor(void f(const T &, const C &, unsigned))
Base class for print_contexts.
print_python(std::ostream &, unsigned options=0)
#define GINAC_DECLARE_PRINT_CONTEXT(classname, supername)
Macro for inclusion in the declaration of a print_context class.
unsigned options
option flags
const char * get_name() const
virtual ~print_functor_impl()
void operator()(const basic &obj, const print_context &c, unsigned level) const
print_functor handler for pointer-to-functions of class T, context type C
Context for C source output using CLN numbers.
std::unique_ptr< print_functor_impl > impl
This class represents a print method for a certain algebraic class and print_context type...
Base context for C source output.
print_functor handler for member functions of class T, context type C
void(* F)(const T &, const C &, unsigned)
void operator()(const basic &obj, const print_context &c, unsigned level) const override
void operator()(const basic &obj, const print_context &c, unsigned level) const override
std::ostream & s
stream to output to
This class stores information about a registered print_context class.
Context for tree-like output for debugging.