Blender V5.0
Id.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11
12#include "MEM_guardedalloc.h"
13
14namespace Freestyle {
15
19class Id {
20 public:
21 typedef uint id_type;
22
25 {
26 _first = 0;
27 _second = 0;
28 }
29
34 {
35 _first = id;
36 _second = 0;
37 }
38
40 Id(id_type ifirst, id_type isecond)
41 {
42 _first = ifirst;
43 _second = isecond;
44 }
45
47 Id(const Id &iBrother)
48 {
49 _first = iBrother._first;
50 _second = iBrother._second;
51 }
52
54 Id &operator=(const Id &iBrother)
55 {
56 _first = iBrother._first;
57 _second = iBrother._second;
58 return *this;
59 }
60
63 {
64 return _first;
65 }
66
69 {
70 return _second;
71 }
72
74 void setFirst(id_type first)
75 {
76 _first = first;
77 }
78
80 void setSecond(id_type second)
81 {
82 _second = second;
83 }
84
86 bool operator==(const Id &id) const
87 {
88 return ((_first == id._first) && (_second == id._second));
89 }
90
92 bool operator!=(const Id &id) const
93 {
94 return !((*this) == id);
95 }
96
98 bool operator<(const Id &id) const
99 {
100 if (_first < id._first) {
101 return true;
102 }
103 if (_first == id._first && _second < id._second) {
104 return true;
105 }
106 return false;
107 }
108
109 private:
110 id_type _first;
111 id_type _second;
112
113 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Id")
114};
115
116// stream operator
117inline std::ostream &operator<<(std::ostream &s, const Id &id)
118{
119 s << "[" << id.getFirst() << ", " << id.getSecond() << "]";
120 return s;
121}
122
123} /* namespace Freestyle */
unsigned int uint
Read Guarded memory(de)allocation.
void setFirst(id_type first)
Definition Id.h:74
bool operator<(const Id &id) const
Definition Id.h:98
id_type getFirst() const
Definition Id.h:62
Id(const Id &iBrother)
Definition Id.h:47
id_type getSecond() const
Definition Id.h:68
void setSecond(id_type second)
Definition Id.h:80
Id(id_type ifirst, id_type isecond)
Definition Id.h:40
uint id_type
Definition Id.h:21
Id(id_type id)
Definition Id.h:33
bool operator==(const Id &id) const
Definition Id.h:86
bool operator!=(const Id &id) const
Definition Id.h:92
Id & operator=(const Id &iBrother)
Definition Id.h:54
inherits from class Rep
Definition AppCanvas.cpp:20
ostream & operator<<(ostream &out, const StrokeAttribute &iStrokeAttribute)
Definition StrokeIO.cpp:16