[Development] Namespaces (was: Qt Platform Extras)

Sze Howe Koh szehowe.koh at gmail.com
Tue Sep 17 12:30:32 CEST 2013


On 17 September 2013 15:10, Saether Jan-Arve <Jan-Arve.Saether at digia.com> wrote:
>>>>> On terça-feira, 10 de setembro de 2013 22:31:53, Sze Howe Koh wrote:
>>>>>> On 10 September 2013 14:27, Knoll Lars <Lars.Knoll at digia.com>
>> wrote:
>>>>>>> Ok, let's use QtWin for the namespace. For the module itself it
>>>>>>> makes IMO to keep the 'Extras' in the name.
>>>>>>
>>>>>> QtWin or QWin?

<snip>

>> Consistent or not, do we want to introduce more namespaces with
>> suboptimal names? IMHO it would be better to go for the optimal naming
>> with new namespaces, and eventually fix the old remaining ones in Qt 6.
>> That would give us cute names and less changes needed in the future
>> while porting to Qt 6.
>>
>> One could also argue whether for example the QSsl namespace is that
>> bad after all. The scope of that particular namespace is to provide
>> enums for a small set of SSL classes, whereas namespaces like QtWin
>> and QtMac are module-wide. To me it would make sense to enforce the
>> QtFoo naming convention for such module-wide enums, but still allow
>> QFoo style naming for "targeted" namespaces.
>>
> I think I agree with JP. AFAICS, no other module is using module-wide namespaces, so it would not be inconsistent to name it QtFoo.

Actually, there are 5 such module-namespace pairs:
    * Qt D-Bus -- QDBus
    * Qt Multimedia -- QMultimedia
    * Qt OpenGL -- QGL
    * Qt SQL -- QSql
    * Qt Test -- QTest

The odd one out is:
    * Qt Concurrent -- QtConcurrent

> Also, using QtFoo makes it consistent with the module-wide include:
> #include <QtFoo>
>
> (And it cannot be #include <QFoo> since that would be inconsistent with our other module-wide includes)

The headers for the namespaces listed above are:
    #include <QDBus>
    #include <QMultimedia>
    #include <QGL>
    #include <QSql>
    #include <QTest>

...and:
    #include <QtConcurrentMap>, #include <QtConcurrentFilter>,
#include <QtConcurrentRun>
(The QtConcurrent namespace is split across different headers)

These namespace includes are NOT the same as module-wide includes. I
think module-wide includes should only ever be used for rapid
prototyping. We should make it possible to use a namespaced function
without pulling in every other class in the module.

Example:
#include <QMultimedia> pulls in the QMultimedia namespace only, but
#include <QtMultimedia> pulls in the QMultimedia namespace PLUS all
the audio, video, radio, camera etc. classes. This can adversely
impact compilation times for large projects.

If we want to start using QtFoo namespaces, I think we should also
decide on a new (and universally-applicable) header scheme. Maybe
#include <QtFooNamespace>?


Regards,
Sze-Howe



More information about the Development mailing list