On Tue, Sep 16, 2003 at 12:33:39PM +0200, Alfredo Braunstein wrote:
> Andre Poenitz wrote:
> 
> > On Tue, Sep 16, 2003 at 12:20:58PM +0200, Alfredo Braunstein wrote:
> >> > I think you could try to convert the math dispatch to your scheme
> >> > without affecting the rest of LyX. This would give some reference
> >> > implementation of the scheme without duplicated work...
> >> 
> >> I was thinking... how about implementing factory.C in a similar way also?
> >> 
> >> Every inset could register a constructor standalone function that returns
> >> a base inset given some data.
> >> 
> >> Does it make sense?
> > 
> > Yes. [And works fine, I do this in my day time job all over the place].
> 
> I must admit that me also. ;-)
>  
> > The only tricky part is to get the 'seemingly unused' static dummy
> > variables
> > whose constructors are used for the registration on startup  from a
> > library in a binary ;-}
> 
> I don't understand this. What I've done (I don't know if it is good practice
> or not is nor if it would work on other systems):
> 
> class registery {
> public:
>         static registery & get();
>         list<pair<identifier, callback> > cblist;
> private:
>         registery() {};
> }
> 
> struct register {
>         register(identifier id, callback cb) { registery::get().push_back(
> make_pair(id ,cb))};
> };
> 
> 
> And I add a
> 
> register reg(id, &cb);

Where exactly?

On file scope?

Does that work if your InsetXXX.o equivalents are placed in a library or
only for direct linking?

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)

Reply via email to