[CMake] Loading Plugins
Aaron Boxer
boxerab at gmail.com
Fri Oct 31 22:44:11 EDT 2014
On Fri, Oct 31, 2014 at 5:48 PM, J Decker <d3ck0r at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20141031/3b320f7c/attachment-0001.html>
More information about the CMake
mailing list