22#ifndef GINAC_CLASS_INFO_H
23#define GINAC_CLASS_INFO_H
88 typedef std::map<std::string, const class_info *> name_map_type;
89 static name_map_type name_map;
90 static bool name_map_initialized =
false;
92 if (!name_map_initialized) {
96 name_map[p->
options.get_name()] = p;
99 name_map_initialized =
true;
102 typename name_map_type::const_iterator it = name_map.
find(class_name);
103 if (it == name_map.end())
104 throw (std::runtime_error(
"class '" + class_name +
"' not registered"));
112 std::string name =
n->info->
options.get_name();
115 std::cout <<
" [ID 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
n->info->options.get_id() << std::dec <<
"]" << std::endl;
117 size_t num_children =
n->children.size();
119 for (
size_t i = 0; i < num_children; ++i) {
121 std::cout << prefix <<
" +- ";
122 if (i == num_children - 1)
123 dump_tree(
n->children[i], prefix +
" ", verbose);
125 dump_tree(
n->children[i], prefix +
" | ", verbose);
127 std::string spaces(name.size(),
' ');
129 std::cout << prefix << spaces;
130 if (num_children == 1)
131 std::cout <<
" --- ";
135 std::cout <<
" -+- ";
136 if (i == num_children - 1)
137 dump_tree(
n->children[i], prefix + spaces +
" ", verbose);
139 dump_tree(
n->children[i], prefix + spaces +
" | ", verbose);
143 std::cout << std::endl;
152 std::vector<tree_node>
tree;
158 for (
typename std::vector<tree_node>::iterator i =
tree.begin(); i !=
tree.end(); ++i) {
161 for (
typename std::vector<tree_node>::iterator j =
tree.begin(); j !=
tree.end(); ++j) {
172 dump_tree(root,
"", verbose);
178 if (!parents_identified) {
180 const char *parent_name = p->options.get_parent_name();
182 if (std::strcmp(q->options.get_name(), parent_name) == 0) {
188 parents_identified =
true;
class_info * get_parent() const
Get pointer to class_info of parent class (or nullptr).
static bool parents_identified
static const class_info * find(const std::string &class_name)
Find class_info by name.
static void dump_hierarchy(bool verbose=false)
Dump class hierarchy to std::cout.
static void identify_parents()
static class_info * first
static void dump_tree(tree_node *n, const std::string &prefix, bool verbose)
std::ostream & tree(std::ostream &os)
std::vector< tree_node * > children
void add_child(tree_node *n)