Would it be reasonable to convert the new event system to use mix-in
templates [1] instead of the CS_EVENT_HANDLER_NAMES macro and friends?
Off the top of my head I'm thinking of a design like the following
(very similar to existing SCF template tricks).
template<char* name> class csNullEventHandlerNames0 { ... };
template<char* name, typename T1> class csNullEventHandlerNames1 :
public T1 { ... };
These would be used as follows.
class csFoo : public
csNullEventHanderNames0<"crystalspace.module.name"> { ... };
class csBar : public
csNullEventHanderNames1<"crystalspace.module.name"> { ... };
In theory this could be generalized higher numbers of parent classes,
but I suspect that in practice csNullEventHandlerNames1 is all we will
ever need (maybe not even csNullEventHandlerNames0). The reason I
suspect this is because most (if not all) uses of the even handlers
will have to be using SCF (because of iEventHandler) and thus be
inheriting from scfImplementation (presuming they have been converted
to the new SCF). As such they will have exactly one parent and will
look like this:
class csBaz : public csNullEventHandlerNames1<"crystalspace.module.name",
scfImplementation2<csBaz, iEventHandler, iFooBarBaz> > { ... };
I am not certain but I think the following would also be valid:
class csFrob : public scfImplementation2<csFrob, iFooBarBaz,
csNullEventHanderNames1<"crystalspace.module.name", iEventHandler> { ... };
Though perhaps in bad taste, if the later is valid, this opens the
possibility of an alternative design:
template<char *name> class csNullEventHandlerNames : public
iEventHandler { ... };
Where csNullEventHandlerNames would be crafted to be validly used in
an interface position for scfImplementation. (I think that would be
easy. Tell me if you think otherwise.) Then we could write:
class csZoe : public scfImplementation2<csZoe, iFooBarBaz,
csNullEventHandlerNames<"crystalspace.module.name"> > { ... };
Throughts? Ideas? Trout?
Michael D. Adams
[EMAIL PROTECTED]
[1] http://www.old.netobjectdays.org/pdf/00/papers/gcse/batorysmar.pdf
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]