23#ifndef GINAC_CLASS_INFO_H
24#define GINAC_CLASS_INFO_H
89 typedef std::map<std::string, const class_info *> name_map_type;
90 static name_map_type name_map;
91 static bool name_map_initialized =
false;
93 if (!name_map_initialized) {
97 name_map[p->
options.get_name()] = p;
100 name_map_initialized =
true;
103 typename name_map_type::const_iterator it = name_map.
find(class_name);
104 if (it == name_map.end())
105 throw (std::runtime_error(
"class '" + class_name +
"' not registered"));
113 std::string name =
n->info->options.get_name();
116 std::cout <<
" [ID 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
n->info->options.get_id() << std::dec <<
"]" << std::endl;
118 size_t num_children =
n->children.size();
120 for (
size_t i = 0; i < num_children; ++i) {
122 std::cout << prefix <<
" +- ";
123 if (i == num_children - 1)
124 dump_tree(
n->children[i], prefix +
" ", verbose);
126 dump_tree(
n->children[i], prefix +
" | ", verbose);
128 std::string spaces(name.size(),
' ');
130 std::cout << prefix << spaces;
131 if (num_children == 1)
132 std::cout <<
" --- ";
136 std::cout <<
" -+- ";
137 if (i == num_children - 1)
138 dump_tree(
n->children[i], prefix + spaces +
" ", verbose);
140 dump_tree(
n->children[i], prefix + spaces +
" | ", verbose);
144 std::cout << std::endl;
153 std::vector<tree_node>
tree;
159 for (
typename std::vector<tree_node>::iterator i =
tree.begin(); i !=
tree.end(); ++i) {
162 for (
typename std::vector<tree_node>::iterator j =
tree.begin(); j !=
tree.end(); ++j) {
173 dump_tree(root,
"", verbose);
179 if (!parents_identified) {
181 const char *parent_name = p->options.get_parent_name();
183 if (std::strcmp(q->options.get_name(), parent_name) == 0) {
189 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)