jvcleave / ofxOMXPlayer

OpenMax accelerated video player for openFrameworks on the Raspberry Pi 0-3. Does not work with RPI4
GNU General Public License v2.0
180 stars 61 forks source link

I want to add const prefix some getter functions as possible #135

Closed leico closed 6 years ago

leico commented 6 years ago

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: 1425b0713e4fe0355368f360d9cbdd4184eaaf9b , also I will try add more const modifier as possible as.

Thank you for reading.

jvcleave commented 6 years ago

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).

leico commented 6 years ago

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; }
leico commented 6 years ago

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() ); }
jvcleave commented 6 years ago

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

leico commented 6 years ago

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