aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/modelinglib/qtserialization/inc/qark/impl/objectid.h
blob: 13e917fe8db3ec80d72131741f0c91cb22a2b259 (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
// Copyright (C) 2016 Jochen Becher
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

namespace qark {
namespace impl {

class ObjectId
{
public:
    explicit ObjectId(int id = -1) : m_id(id) { }

    int get() const { return m_id; }
    void set(int id) { m_id = id; }
    bool isValid() const { return m_id >= 0; }

    ObjectId operator++(int) { ObjectId id(*this); ++m_id; return id; }

private:
    int m_id = 1;
};

inline bool operator<(const ObjectId &lhs, const ObjectId &rhs)
{
    return lhs.get() < rhs.get();
}

} // namespace impl
} // namespace qark