On Fri, Oct 31, 2014 at 5:48 PM, J Decker <d3c...@gmail.com> wrote:

>
> really nothing at all to do with cmake; a couple macros and you can
> support cross-platform... a few less and you can init interfaces pretty
> easily....
> at the end of init or during early discovery of functions, if they fail
> you can fillthe interface with static methods or return a different
> interface....
>
> code part of
> https://code.google.com/p/c-system-abstraction-component-gui/source/browse/src/streamlib/ffmpeg/ffmpeg_interface.c
>
>
> #ifdef WIN32
> #define lib_format WIDE("avformat-56.dll")
> #else
>
> #if defined( __ANDROID__) || defined( __LINUX__ )
> #define lib_format WIDE("libavformat.so")
> #endif
>
> static struct fmpeg_interface
> {
> #define declare_func(a,b,c) a (CPROC *b) c
> #define setup_func(lib, a,b,c) if( ffmpeg.b=(a(CPROC*)c)LoadFunction( lib,
> _WIDE(#b) ) )
>
> declare_func( void, av_register_all,(void) );
> declare_func( int, avformat_open_input, (AVFormatContext **ps, const char
> *filename, AVInputFormat *fmt, AVDictionary **options) );
> /*...*/
> } ffmpeg;
>
>
> void Init( void )
> {
>  setup_func( lib_format, void, av_register_all,(void) );
> setup_func( lib_format, int, avformat_open_input, (AVFormatContext **,
> const char *, AVInputFormat *, AVDictionary **) );
> setup_func( lib_format, int, avformat_close_input, (AVFormatContext **) );
>  }
>
> void LaterUsage( void )
> {
> ffmpeg.av_register_all();
> }
>
> void LaterUsageAsPointer( void )
> {
> struct fmpeg_interface interface = &ffmpeg; /* or from some other function
> */
> interface->av_register_all();
> }
>
> if you have intellisense, makes for nice popups of available methods.
>
>
Thanks. After a little Googling, I found this Dr. Dobbs article that
describes, with source code, how create a plugin architecture.

Aaron
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to