SleakEngine
1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Object.hpp
Go to the documentation of this file.
1
#ifndef _OBJECT_H_
2
#define _OBJECT_H_
3
4
#include <cstdint>
5
#include <string>
6
#include <atomic>
7
8
namespace
Sleak
{
9
/// Base for anything needing a stable identity: a name and a
10
/// process-unique, atomically assigned ID.
11
/// @ingroup core
12
class
Object
{
13
public
:
14
Object
(
const
std::string& name =
"Object"
)
15
: m_uniqueID(s_nextUniqueID.fetch_add(1, std::memory_order_relaxed)),
16
m_name(name)
17
{
18
SetName
(m_name +
"-"
+ std::to_string(m_uniqueID));
19
}
20
21
virtual
~Object
() =
default
;
22
23
uint64_t
GetUniqueID
()
const
{
return
m_uniqueID; }
24
25
const
std::string&
GetName
()
const
{
return
m_name; }
26
27
inline
void
SetName
(
const
std::string& value) { m_name = value; }
28
29
private
:
30
std::string m_name;
31
uint64_t m_uniqueID;
32
static
inline
std::atomic<uint64_t> s_nextUniqueID = 0;
33
};
34
}
35
36
#endif
Sleak::Object::~Object
virtual ~Object()=default
Sleak::Object::SetName
void SetName(const std::string &value)
Definition
Object.hpp:27
Sleak::Object::GetName
const std::string & GetName() const
Definition
Object.hpp:25
Sleak::Object::Object
Object(const std::string &name="Object")
Definition
Object.hpp:14
Sleak::Object::GetUniqueID
uint64_t GetUniqueID() const
Definition
Object.hpp:23
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
include
public
Core
Object.hpp
Generated on
for SleakEngine by
1.16.1