-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
src/C4Com.h | ||
src/C4CrashHandlerWin32.cpp | ||
src/C4FileClasses.cpp | ||
src/C4Windows.h | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* LegacyClonk | ||
* | ||
* Copyright (c) 2023, The LegacyClonk Team and contributors | ||
* | ||
* Distributed under the terms of the ISC license; see accompanying file | ||
* "COPYING" for details. | ||
* | ||
* "Clonk" is a registered trademark of Matthes Bender, used with permission. | ||
* See accompanying file "TRADEMARK" for details. | ||
* | ||
* To redistribute this file separately, substitute the full license texts | ||
* for the above references. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "C4WinRT.h" | ||
|
||
#include <utility> | ||
|
||
class C4Com | ||
{ | ||
public: | ||
C4Com() = default; | ||
|
||
explicit C4Com(const winrt::apartment_type apartmentType) | ||
{ | ||
MapHResultError(&winrt::init_apartment, apartmentType); | ||
initialized = true; | ||
} | ||
|
||
~C4Com() | ||
{ | ||
if (initialized) | ||
{ | ||
winrt::uninit_apartment(); | ||
} | ||
} | ||
|
||
C4Com(const C4Com &) = delete; | ||
C4Com &operator=(const C4Com &) = delete; | ||
|
||
C4Com(C4Com &&other) noexcept | ||
: initialized{std::exchange(other.initialized, false)} | ||
{ | ||
} | ||
|
||
C4Com &operator=(C4Com &&other) noexcept | ||
{ | ||
initialized = std::exchange(other.initialized, false); | ||
return *this; | ||
} | ||
|
||
private: | ||
bool initialized{false}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters