summaryrefslogtreecommitdiffstats
path: root/src/track/trackref.cpp
blob: 60d48911f1d5a147bb7ac70d1e62f0b97f3f9a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "track/trackref.h"

#include <QDebugStateSaver>

bool TrackRef::verifyConsistency() const {
    // Class invariant: The location can only be set together with
    // at least one of the other members!
    VERIFY_OR_DEBUG_ASSERT(!hasCanonicalLocation() || hasLocation()) {
        // Condition violated: hasCanonicalLocation() => hasLocation()
        return false;
    }
    VERIFY_OR_DEBUG_ASSERT(!hasId() || hasLocation()) {
        // Condition violated: hasId() => hasLocation()
        return false;
    }
    return true;
}

std::ostream& operator<<(std::ostream& os, const TrackRef& trackRef) {
    return os
            << "TrackRef{"
            << trackRef.getLocation().toStdString()
            << ','
            << trackRef.getCanonicalLocation().toStdString()
            << ','
            << trackRef.getId()
            << '}';
}

QDebug operator<<(QDebug dbg, const TrackRef& trackRef) {
    const QDebugStateSaver saver(dbg);
    dbg = dbg.maybeSpace() << "TrackRef";
    return dbg.nospace()
            << '{'
            << trackRef.getLocation()
            << ','
            << trackRef.getCanonicalLocation()
            << ','
            << trackRef.getId()
            << '}';
}