Passing derived class transactions to a base class analysis port

I have a base class and at least 2 derived classes that extend the base class :

class base_class extends uvm_sequence_item;

class der_class1 extends base_class;

class der_class2 extends base_class;

I have an analysis port in my monitor of base class type :

uvm_analysis_port#(base_class) base_class_ap;

My monitor constructs only the different derived class objects. Can I just pass the derived class to the base class analysis port?

der_class1 tr1;
… construct and populate …


der_class2 tr2;
… construct and populate …

On the export end I assume I would need to do a $cast(der_class1_obj, base_class_obj) to convert the transactions back to their correct derived class?

Any corrections to what I have here?

In reply to sperber:

Nope. You’ve got it exactly right.

Yes, you can use the base_class reference the class1 and class2
in export, use $cast(class1, base_class) to check the item received from port is
the type you wanted. if the base_class ref object type is not you wanted eg. class2,
the $cast shall return false.