Skip to content
Snippets Groups Projects
Commit c46ed133 authored by Matěj Laitl's avatar Matěj Laitl
Browse files

Biggie: introduce core/meta/forward_declarations.h and use it

We try to include only what is absolutely necessary in header
files to keep compilation times low. This is especially useful not
during the first compilation, but when you touch one (header) file ->
the less this header is (transitively) included, the less files you
need to recompile.

Normally, forward declarations of all-but-direct members of the class
help with this immensely. However, all our meta types use KSharedPtrs
instead of plain pointers (for good reasons); forward-declaring these
is well possible, but tedious to do in each header file that uses them.

Introduce core/meta/forward_declarations.h that contains forward
declarations of all KSharedPtr-managed classes in core/meta/* (and
KSharedPtr include for convenience)

Use the new file where appropriate. Now all header files should include
core/meta/forward_declarations.h instead of Meta.h (and include Meta.h
just in the .cpp file), unless they actually subclass one of those
classes.

Note that forward_declarations.h suffices even when you have
Meta::[Something]Ptr as class attribute; with a small hiccup: your
destructor needs to be implemented (even if empty) in a file that
includes the full class declaration (the compiler catches this
fortunately) of the meta class. That's why this patch add some
seemingly redundant empty destructor implementations.

Another hiccup is when you use Meta::[Something]Ptrs inside Qt
signals/slots - the code that ends up in the .moc (or *_automoc.cpp)
file and will usually need the full class declaration; simple trick is
to add the old-style
 #include "FooClass.moc" at the end of the file.

This is not that important per-se, but it paves the way for more Meta
changes that we sketched in Randa.

CCMAIL: amarok-devel@kde.org
parent 4589f4d1
No related branches found
No related tags found
Loading
Showing
with 57 additions and 39 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment