Blender V4.3
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
12#ifdef WITH_CXX_GUARDEDALLOC
13# include "MEM_guardedalloc.h"
14#endif
15
16namespace Freestyle {
17
21class Id {
22 public:
23 typedef uint id_type;
24
27 {
28 _first = 0;
29 _second = 0;
30 }
31
36 {
37 _first = id;
38 _second = 0;
39 }
40
42 Id(id_type ifirst, id_type isecond)
43 {
44 _first = ifirst;
45 _second = isecond;
46 }
47
49 Id(const Id &iBrother)
50 {
51 _first = iBrother._first;
52 _second = iBrother._second;
53 }
54
56 Id &operator=(const Id &iBrother)
57 {
58 _first = iBrother._first;
59 _second = iBrother._second;
60 return *this;
61 }
62
65 {
66 return _first;
67 }
68
71 {
72 return _second;
73 }
74
76 void setFirst(id_type first)
77 {
78 _first = first;
79 }
80
82 void setSecond(id_type second)
83 {
84 _second = second;
85 }
86
88 bool operator==(const Id &id) const
89 {
90 return ((_first == id._first) && (_second == id._second));
91 }
92
94 bool operator!=(const Id &id) const
95 {
96 return !((*this) == id);
97 }
98
100 bool operator<(const Id &id) const
101 {
102 if (_first < id._first) {
103 return true;
104 }
105 if (_first == id._first && _second < id._second) {
106 return true;
107 }
108 return false;
109 }
110
111 private:
112 id_type _first;
113 id_type _second;
114
115#ifdef WITH_CXX_GUARDEDALLOC
116 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Id")
117#endif
118};
119
120// stream operator
121inline std::ostream &operator<<(std::ostream &s, const Id &id)
122{
123 s << "[" << id.getFirst() << ", " << id.getSecond() << "]";
124 return s;
125}
126
127} /* namespace Freestyle */
unsigned int uint
Read Guarded memory(de)allocation.
void setFirst(id_type first)
Definition Id.h:76
bool operator<(const Id &id) const
Definition Id.h:100
id_type getFirst() const
Definition Id.h:64
Id(const Id &iBrother)
Definition Id.h:49
id_type getSecond() const
Definition Id.h:70
void setSecond(id_type second)
Definition Id.h:82
Id(id_type ifirst, id_type isecond)
Definition Id.h:42
uint id_type
Definition Id.h:23
Id(id_type id)
Definition Id.h:35
bool operator==(const Id &id) const
Definition Id.h:88
bool operator!=(const Id &id) const
Definition Id.h:94
Id & operator=(const Id &iBrother)
Definition Id.h:56
inherits from class Rep
Definition AppCanvas.cpp:20
ostream & operator<<(ostream &out, const StrokeAttribute &iStrokeAttribute)
Definition StrokeIO.cpp:16