Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
GUIDWrapper.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32/*Code references:
33 http://www.cplusplus.com/forum/lounge/27570/
34*/
35
36
37#pragma once
38#ifndef DVD_GUID_WRAPPER_H_
39#define DVD_GUID_WRAPPER_H_
40
41namespace Divide {
42
45 public:
46 GUIDWrapper() noexcept : _guid(generateGUID()) {}
47 GUIDWrapper([[maybe_unused]] const GUIDWrapper& old) noexcept : _guid(generateGUID()) { }
48 GUIDWrapper(GUIDWrapper&& old) noexcept : _guid(old._guid) {}
49 virtual ~GUIDWrapper() = default;
50
51 [[nodiscard]] FORCE_INLINE I64 getGUID() const noexcept { return _guid; }
52
53 static I64 generateGUID() noexcept;
54
55 GUIDWrapper& operator=(const GUIDWrapper& old) = delete;
56 GUIDWrapper& operator=(GUIDWrapper&& other) = delete;
57
58 protected:
59 const I64 _guid;
60};
61
62FORCE_INLINE bool operator==(const GUIDWrapper& lhs, const GUIDWrapper& rhs) noexcept
63{
64 return lhs.getGUID() == rhs.getGUID();
65}
66
67FORCE_INLINE bool operator!=(const GUIDWrapper& lhs, const GUIDWrapper& rhs) noexcept
68{
69 return lhs.getGUID() != rhs.getGUID();
70}
71
72[[nodiscard]]
73FORCE_INLINE bool Compare(const GUIDWrapper* const lhs, const GUIDWrapper* const rhs) noexcept
74{
75 if (lhs != nullptr && rhs != nullptr)
76 {
77 return lhs->getGUID() == rhs->getGUID();
78 }
79
80 return (lhs == nullptr && rhs == nullptr);
81}
82
83
84} // namespace Divide
85
86#endif //DVD_GUID_WRAPPER_H_
#define FORCE_INLINE
Utility class that adds basic GUID management to objects.
Definition: GUIDWrapper.h:44
GUIDWrapper(const GUIDWrapper &old) noexcept
Definition: GUIDWrapper.h:47
GUIDWrapper(GUIDWrapper &&old) noexcept
Definition: GUIDWrapper.h:48
static I64 generateGUID() noexcept
Definition: GUIDWrapper.cpp:5
virtual ~GUIDWrapper()=default
GUIDWrapper() noexcept
Definition: GUIDWrapper.h:46
FORCE_INLINE I64 getGUID() const noexcept
Definition: GUIDWrapper.h:51
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
FORCE_INLINE bool operator!=(const GUIDWrapper &lhs, const GUIDWrapper &rhs) noexcept
Definition: GUIDWrapper.h:67
FORCE_INLINE bool Compare(const GUIDWrapper *const lhs, const GUIDWrapper *const rhs) noexcept
Definition: GUIDWrapper.h:73
int64_t I64