Replace dynamic_cast with virtual functions.

apitrace can be built with without RTTI (runtime type information)
providing that dynamic_cast isn't used.