Hi,

The Open Movie Editor uses quite bit of casting, namely because there is a lot of interaction between the basic framework, that handels simple “Track” and “Clip” objects, and more specific upper layers that handle objects like “AudioTrack” or “VideoClip”. Up to now I always used the old C-style cast operator, like:
AudioTrack* at = (AudioTrack*)t;

This had some disadvantages, because if t is not a real AudioTrack, but instead a VideoTrack, than everything would screw up. Of course this shouldn’t happen anyway because of various measures to avoid this type of corruption, but who knows.

This is where the dynamic_cast operator comes into play, it’s one of several modern C++ aquivalents to the older C cast, and looks like this:
AudioTrack* at = dynamic_cast<AudioTrack*>(t);

It does pretty much the same as the other variant, however there is one important difference, in case t is not what it’s ought to be, it will return 0. Therefore variations are easier to detect programmatically and in the debugger.

Have fun.

-Richard

Tags Development, Open Movie Editor

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image