jvcleave / ofxOMXPlayer

OpenMax accelerated video player for openFrameworks on the Raspberry Pi 0-3. Does not work with RPI4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I want to add const prefix some getter functions as possible

leico opened this issue · comments

commented

Hello jvcleave, thank you to create a awesome addon!

Now I trying to create apps with this addon. When read this addons source codes, I got worried that getter functions returned non const values, also they are not const function.
I prefer a const modifier, it helps compiler optimization. ah, const becomes a slightly more complicated code.
Which is preferable ?

If you like, I will send PR like: 1425b07 , also I will try add more const modifier as possible as.

Thank you for reading.

Thanks but I am not a huge fan of const as I am often trying to work around it with other libraries.

As far as I have found it doesn't effect performance (the compiler does it's checks and deletes it).

commented

Thank you quick reply.

It seems I had generated religious war unintentionally, I planned to use getters in other const functions with other library const functions...

It may not be a good method ( it becomes complicate ), how do you think to use overloads? like:

      int some_getter ( void )       { return value; }
const int some_getter ( void ) const { return value; }
commented

Ah, I remembered effective C++, this is more easier maintain codes.

const int& some_getter( void ) const { return value; }
      int& some_getter( void )       { return const_cast< int& >( some_getter() ); }

I think the best thing for you is to write a wrapper for yourself. see ofRPIVideoPlayer.h which does some of what you are talking about

commented

Thank you to consider my suggestion, yeah I'll try wrapper or inherit class.