Okay, I'll resend this mail with fixed line-breaks -_- On Tuesday 27 July 2010 15:29:37 Zoltan Padrah wrote: > Hello, > > In the current implementation, > the template shouldn't be instantiated directly. > For an example, see the basic_ec plugin. > > The DECLARE_ELEMENT_FACTORY_MEMBER > macro can be used to declare a variable > of the template type, usually in a class. > > REGISTER_ELEMENT_FACTORY creates > an instance of the above declared > member and registers it in the > simulation manager. > > UNREGISTER_ELEMENT_FACTORY unregisters the > instance. > > All 3 macros take as parameter only the type of the new > element. > > The template class has the parameter <class ElementType> the > new element type, and its constructor takes as > argument the ID of the element type. It's not > necessary to instantiate the template manually. > > This implementation could be used from any plugin, so it should be > moved somewhere else, I guess in the interfaces folder. Ahh, okay. I got it :)
> Other
implementation, that would scale even better,
> could be used as
following:
>
> outside of any class:
>
> DECLARE_ELEMENT_FACTORY(
>
FactoryName,
> SUPPORT_ELEMENT( Element1 )
> SUPPORT_ELEMENT( Element2 )
>
// and so on...
> );
>
> And the plugin can look like:
>
> class
>
MyPlugin : public IPlugin {
> FactoryName *m_factory;
>
> MyPlugin() {
>
m_factory = new FactoryName();
>
ISimulationManager::self()->registerElementFactory(m_factory);
> }
> void
unload(){
>
ISimulationManager::self()->unregisterElementFactory(m_factory);
> }
>
};
>
> This way, adding 1 new component takes 2 new lines in the source:
one
> for including its header, and the other to call a macro.
>
> The
implementation of the macros could be done by using many if-s
> internally,
but that shouldn't be visible to the programmer.
>
> Opinions about this?
I
think, I'd support that one. Looks pretty similar to what
I had in mind,
some hours ago.
The macro might be a little more complex, but once done,
it
would be easy to add new elements.
I can also imagine, that this can be
easily extended to
work with scripted plugins, too.
> 2010/7/27, Julian
Bäume <[email protected]>:
> > This could look like:
> >
> > // my cool
> >
// resistor
> > // implementation
> > DECLARE_ELEMENT_FACTORY(
> >
KTechLab::Element::Resistor
> > );
> >
> > REGISTER_ELEMENT_FACTORY(
> >
ElementFactory<KTechLab::Element::Resistor>
> > );
> >
> > class
KTechLab::Element::Resistor
> > : public IElement
> >{
> >
//implementation
> > };
bye then
julian
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://ad.doubleclick.net/clk;226879339;13503038;l? http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________ Ktechlab-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ktechlab-devel
