[Clam-devel] Commit #11195: templated plugins generator

Xavier Amatriain xavier at amatriain.net
Thu Feb 21 01:32:48 PST 2008


Hernan, this is great! Actually it is pretty much in line with the idea 
we have had for a long time to be
able to develop CLAM Processing classes by just specifying the Do 
operation and the type of the ports.

We should think on continuing this line of work in a GSoC project if we 
are in this year.

Hernán Ordiales wrote:
> Hi all,
>
> The story:
> Every time i started a new plugin most times i had to open another
> processing class and copy those files and made a lot of search&replace
> until really start coding. So i ended up making some basic processings
> to always start from there. i.e. two audio inputs and one control
> without configuration, another with a config, etc. But this still
> requires some mechanical work every time for changes the names (again
> search&replace), etc.
> So, some time ago i had the idea of a make a simple python script to
> do all that job based in base processings (or "templates"). And now i
> have done it :-D
>
> Side benefits:
> I think this is also useful to avoid bad(old) practices in new people
> starting to develop plugins taking base code from everywhere...
>
> Details:
> Usage: ./TemplatedPluginsGenerator.py NEWPLUGINNAME TEMPLATENAME
> [COPYRIGHTHOLDER] [LICENSE] [YEAR]
>
> i.e: ./TemplatedPluginsGenerator.py TemplatedPluginTest simple
> "Fundació Barcelona Media Universitat Pompeu Fabra" GPL 2007
>
> will generate a TemplatedPluginTest.hxx like:
>
> /*
>  * Copyright (c) 2007 Fundació Barcelona Media Universitat Pompeu Fabra
>  *
>  *
>  * This program is free software; you can redistribute it and/or modify
>  * it under the terms of the GNU General Public License as published by
>  * the Free Software Foundation; either version 2 of the License, or
>  * (at your option) any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>  *
>  */
>
> #ifndef _TemplatedPluginTest_
> #define _TemplatedPluginTest_
>
> ....(common includes, depends on the chosen template)
>
> namespace CLAM{
>
> 	/**	\brief Short description
> 	 *
> 	 *	Description
> 	 */
> 	class TemplatedPluginTest: public Processing
> 	{
> .... (common members, depends on the chosen template)
>         };
>
> };//namespace CLAM
>
> #endif // _TemplatedPluginTest_
>
> And something similar with TemplatedPluginTest.cxx and if exists, will
> also copy the SConstruct (this one is also edited), README and
> options.cache files.
>
> After that is really ready to start coding and only remains execute
> 'scons install' to have it working at NetworkEditor.
>
> # Specification:
> #   - Available templates are folders with files named
> 'BaseProcessing.hxx', 'BaseProcessing.cxx', 'SConstruct', 'README' and
> 'options.cache' (all them are optional).
> #   - Available licenses are txt files at the 'licenses' folder.
> #   - C++ template files have an unique class named 'BaseProcessing'
> which will be renamed to the plugin name given at commnand prompt.
> #   - In the generated files (new plugin) 'BaseProcessing.hxx' and
> 'BaseProcessing.cxx' files will be renamed to the plugin name keeping
> the extension.
> #   - 'SConstruct' will be edited to give the to libraryName var the
> plugin name in lowercase.
> #   - 'README' and 'options.cache' will be verbatim copies.
> #   - The new plugin will be generated at the 'plugins' folder.
>
> It's all at CLAM/plugins/TemplatedPluginsGenerator dir
>
> hope find it useful...
>
> Best,
>   






More information about the clam-devel mailing list