Let’s assume I have a some class which was derived unknown number of times (inherited) from some base class…
Is there any function or elegant way to retrieve and return the ordered list from the first base class till the last node in inheritance tree?
For example:
class A extends uvm_object/component;
class B extends A;
class C extends B;
class D extends C;
class K extends A;
Calling the func(uvm_object/component class_inst)
will do next:
func(D) - returns: A,B,C
func(K) - returns: A
There is nothing built into the UVM that does this, although there might be some function to aide in the development of your own functions that could do this.
But before anyone spends a lot of time trying to come up with a solution for you, it might help to explain what you intend to do with this information so we don’t end up with an XY problem.
Not an XY problem.
Just asking out of curiosity, as some professional riddle or challenge.
Not sure if it achievable at all.
uvm_component has the next hierarchy functions:
get_parent()
get_child()
get_children()
get_next_child()
get_depth()
But this is only structural UVM functions, not ones that can show the inheritance tree, please correct me if I am wrong.
For uvm_object I don’t know of any related hierarchy functions.
Maybe defining a queue of strings or classes, that for each time we derive from base class we should push another item into this queue.
But how to keep few queues like that?
Or to implement it as a binary tree data structure?
So when we will call the func(D) or func(K) it will just print the items present in the queue or the tree from the leaf node to the root node …
Could it work?