[kde-edu]: Templates or not ?

Benoît Jacob jacob at math.jussieu.fr
Tue Nov 20 20:05:36 CET 2007


On Tuesday 20 November 2007 18:43:18 Vladimir wrote:
> On Monday 19 November 2007 22:21:16 Benoit Jacob wrote:
> > It will be in *internal* headers and that code will be specialized and
> > compiled into your library's binary. Afterwards, the user only sees the
> > binary. The public headers don't have to contain any templated code, they
> > only need to contain declarations of the types (like Vector3d) which may
> > be templates, but that's not an issue, the bigger part of the code is in
> > your shared binary library, only a lightweight part remains in your
> > headers.
>
> Yes, but in my case the library has only a small number of internal
> classes that can be moved to private headers. Basically there is a World
> class which acts as a container for many (public) classes that represents
> physical entities such as bodies or forces or some utilities such as
> solvers and that should be created and inserted into World by the user. And
> almost all logic is implemented as public or private members of
> user-visible classes. Now I want to have World2d and World3d containers
> that can contain 2d or 3d versions of objects respectively.

If you have the logic in user-visible classes, that means that changing the 
logic will typically break binary compatibility. The usual trick to work 
around that is to defer the logic to non-user-visible classes. This is 
actually part of the general idea of d-pointers -- the logic of a class is 
deferred to the d-pointer class. So if you eventually make a binary library, 
you will anyway have to make deep changes, putting much more stuff in 
non-user-visible classes.

See this regarding binary compatibilty:
http://techbase.kde.org/Policies/Library_Code_Policy

> Ok, so lets postpone this discussion till the meeting. You have already
> helped me a lot, now the problem looks quite clearer for me. Thanks a lot !

Good idea, thanks :) Just correcting a pile of 60 student tests, /me is going 
crazy :D

Cheers,
Benoit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kde-edu/attachments/20071120/f9d4b75c/attachment.pgp 


More information about the kde-edu mailing list