Blender  V3.3
Id.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #ifdef WITH_CXX_GUARDEDALLOC
11 # include "MEM_guardedalloc.h"
12 #endif
13 
14 namespace Freestyle {
15 
19 class Id {
20  public:
21  typedef unsigned id_type;
22 
24  Id()
25  {
26  _first = 0;
27  _second = 0;
28  }
29 
33  Id(id_type id)
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 
62  id_type getFirst() const
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 #ifdef WITH_CXX_GUARDEDALLOC
114  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Id")
115 #endif
116 };
117 
118 // stream operator
119 inline std::ostream &operator<<(std::ostream &s, const Id &id)
120 {
121  s << "[" << id.getFirst() << ", " << id.getSecond() << "]";
122  return s;
123 }
124 
125 } /* namespace Freestyle */
Read Guarded memory(de)allocation.
void setFirst(id_type first)
Definition: Id.h:74
bool operator<(const Id &id) const
Definition: Id.h:98
unsigned id_type
Definition: Id.h:21
id_type getFirst() const
Definition: Id.h:62
Id(const Id &iBrother)
Definition: Id.h:47
id_type getSecond() const
Definition: Id.h:68
Id & operator=(const Id &iBrother)
Definition: Id.h:54
Id()
Definition: Id.h:24
void setSecond(id_type second)
Definition: Id.h:80
Id(id_type ifirst, id_type isecond)
Definition: Id.h:40
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
inherits from class Rep
Definition: AppCanvas.cpp:18
ostream & operator<<(ostream &out, const StrokeAttribute &iStrokeAttribute)
Definition: StrokeIO.cpp:14