Skip to content
This repository was archived by the owner on Oct 7, 2023. It is now read-only.

Commit 41a5799

Browse files
committed
색상 브러시는 핸들 인터페이스임
1 parent bdfa4ba commit 41a5799

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

FreeGLUT/ColourBrush.ixx

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,68 @@ module;
33

44
export module Glib.Device.Brush;
55
import <type_traits>;
6+
import Glib.Device.IHandle;
67

78
export namespace gl::device
89
{
910
using NativeColorBrush = ::HBRUSH__*;
1011

11-
class [[nodiscard]] ColorBrush
12+
class [[nodiscard]] ColorBrush : public IHandle<NativeColorBrush>
1213
{
1314
public:
15+
using base = IHandle<NativeColorBrush>;
16+
1417
constexpr ColorBrush() noexcept = default;
1518

1619
constexpr ColorBrush(nullptr_t) noexcept
17-
: myBrush(nullptr)
20+
: base(nullptr)
1821
{}
1922

20-
~ColorBrush() noexcept
21-
{
22-
::DeleteObject(myBrush);
23-
}
24-
2523
explicit constexpr ColorBrush(const NativeColorBrush& brush) noexcept
26-
: myBrush(brush)
24+
: base(brush)
2725
{}
2826

2927
explicit constexpr ColorBrush(NativeColorBrush&& brush) noexcept
30-
: myBrush(std::move(brush))
28+
: base(std::move(brush))
3129
{}
3230

33-
constexpr ColorBrush& operator=(const NativeColorBrush& brush) noexcept
31+
~ColorBrush() noexcept
3432
{
35-
myBrush = brush;
36-
return *this;
33+
Destroy();
3734
}
3835

39-
constexpr ColorBrush& operator=(NativeColorBrush&& brush) noexcept
36+
void Destroy() noexcept
4037
{
41-
myBrush = std::move(brush);
42-
return *this;
43-
}
44-
45-
ColorBrush& operator=(nullptr_t) noexcept
46-
{
47-
if (nullptr != myBrush)
38+
if (nullptr != GetHandle())
4839
{
49-
::DeleteObject(myBrush);
40+
Delegate(::DeleteObject);
41+
base::operator=(nullptr);
5042
}
51-
myBrush = nullptr;
43+
}
5244

45+
constexpr ColorBrush& operator=(const NativeColorBrush& brush) noexcept
46+
{
47+
base::operator=(brush);
5348
return *this;
5449
}
5550

56-
[[nodiscard]]
57-
constexpr const NativeColorBrush& GetHandle() const& noexcept
51+
constexpr ColorBrush& operator=(NativeColorBrush&& brush) noexcept
5852
{
59-
return myBrush;
53+
base::operator=(std::move(brush));
54+
return *this;
6055
}
6156

62-
[[nodiscard]]
63-
constexpr NativeColorBrush&& GetHandle() && noexcept
57+
ColorBrush& operator=(nullptr_t) noexcept
6458
{
65-
return std::move(myBrush);
59+
Destroy();
60+
61+
return *this;
6662
}
6763

6864
ColorBrush(const ColorBrush&) = delete;
6965
constexpr ColorBrush(ColorBrush&&) noexcept = default;
7066
ColorBrush& operator=(const ColorBrush&) = delete;
7167
constexpr ColorBrush& operator=(ColorBrush&&) noexcept = default;
72-
73-
NativeColorBrush myBrush = nullptr;
7468
};
7569

7670
[[nodiscard]]

0 commit comments

Comments
 (0)