summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2013-09-27 13:22:59 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-27 16:18:29 +0200
commit9ff81bdc1ab4e3d14914192cd63ae625a507fe90 (patch)
treed242b18557648e43ca2cda960e61aaa097bc2133
parent29585ec3d3ba0316d3a28d5fd1c383f2b82f8827 (diff)
Use a pimpl in QLoggingCategory
With the usual pros/cons. Cleans up the publicly visible interface and gives some headroom for further extensions. Change-Id: I7237b1fd2a22c66574d1b7e532d99137bb56ce1d Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r--src/corelib/io/qloggingcategory.cpp30
-rw-r--r--src/corelib/io/qloggingcategory.h5
2 files changed, 26 insertions, 9 deletions
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index 80acee6ad1..24eeb1584c 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -98,13 +98,28 @@ Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory,
*/
/*!
+ \internal
+*/
+typedef QVector<QTracer *> Tracers;
+
+/*!
+ \internal
+*/
+class QLoggingCategoryPrivate
+{
+public:
+ Tracers tracers;
+};
+
+/*!
Constructs a QLoggingCategory object with the provided \a category name.
The object becomes the local identifier for the category.
If \a category is \c{0}, the category name is changed to \c{"default"}.
*/
QLoggingCategory::QLoggingCategory(const char *category)
- : name(0),
+ : d(new QLoggingCategoryPrivate),
+ name(0),
enabledDebug(false),
enabledWarning(true),
enabledCritical(true),
@@ -133,6 +148,7 @@ QLoggingCategory::~QLoggingCategory()
{
if (QLoggingRegistry *reg = QLoggingRegistry::instance())
reg->unregisterCategory(this);
+ delete d;
}
/*!
@@ -459,7 +475,7 @@ void QLoggingCategory::setFilterRules(const QString &rules)
void QTracer::addToCategory(QLoggingCategory &category)
{
- category.tracers.append(this);
+ category.d->tracers.append(this);
}
/*!
@@ -571,7 +587,7 @@ void QTracer::addToCategory(QLoggingCategory &category)
void QTraceGuard::start()
{
- QLoggingCategory::Tracers &tracers = target->tracers;
+ const Tracers &tracers = target->d->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->start();
}
@@ -584,7 +600,7 @@ void QTraceGuard::start()
void QTraceGuard::end()
{
- QLoggingCategory::Tracers &tracers = target->tracers;
+ const Tracers &tracers = target->d->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->end();
}
@@ -599,7 +615,7 @@ void QTraceGuard::end()
QTraceGuard &QTraceGuard::operator<<(int msg)
{
- QLoggingCategory::Tracers &tracers = target->tracers;
+ const Tracers &tracers = target->d->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->record(msg);
return *this;
@@ -614,7 +630,7 @@ QTraceGuard &QTraceGuard::operator<<(int msg)
QTraceGuard &QTraceGuard::operator<<(const char *msg)
{
- QLoggingCategory::Tracers &tracers = target->tracers;
+ const Tracers &tracers = target->d->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->record(msg);
return *this;
@@ -630,7 +646,7 @@ QTraceGuard &QTraceGuard::operator<<(const char *msg)
QTraceGuard &QTraceGuard::operator<<(const QVariant &msg)
{
- QLoggingCategory::Tracers &tracers = target->tracers;
+ const Tracers &tracers = target->d->tracers;
for (int i = tracers.size(); --i >= 0; )
tracers.at(i)->record(msg);
return *this;
diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h
index 23b25b5e3f..70192fef13 100644
--- a/src/corelib/io/qloggingcategory.h
+++ b/src/corelib/io/qloggingcategory.h
@@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE
class QTracer;
class QTraceGuard;
+class QLoggingCategoryPrivate;
class Q_CORE_EXPORT QLoggingCategory
{
@@ -80,18 +81,18 @@ public:
static void setFilterRules(const QString &rules);
private:
+ friend class QLoggingCategoryPrivate;
friend class QLoggingRegistry;
friend class QTraceGuard;
friend class QTracer;
+ QLoggingCategoryPrivate *d;
const char *name;
bool enabledDebug;
bool enabledWarning;
bool enabledCritical;
bool enabledTrace;
- typedef QVector<QTracer *> Tracers;
- Tracers tracers;
};
template <>