Leviathan  0.8.0.0
Leviathan game engine
Leviathan::IDFactory Class Reference

#include <IDFactory.h>

+ Inheritance diagram for Leviathan::IDFactory:

Public Member Functions

DLLEXPORT IDFactory ()
 
DLLEXPORT ~IDFactory ()
 
DLLEXPORT int ProduceID ()
 
DLLEXPORT int ProduceSystemID ()
 
- Public Member Functions inherited from Leviathan::ThreadSafeGeneric< MutexType >
DLLEXPORT ThreadSafeGeneric ()
 
DLLEXPORT ~ThreadSafeGeneric ()
 
FORCE_INLINE void VerifyLock (RecursiveLock &guard) const
 
FORCE_INLINE void VerifyLock (Lock &lockit) const
 

Static Public Member Functions

static int GetID ()
 
static int GetSystemID ()
 
static DLLEXPORT IDFactoryGet ()
 

Additional Inherited Members

- Protected Attributes inherited from Leviathan::ThreadSafeGeneric< MutexType >
MutexType ObjectsLock
 

Detailed Description

Definition at line 11 of file IDFactory.h.

Constructor & Destructor Documentation

◆ IDFactory()

IDFactory::IDFactory ( )

Definition at line 5 of file IDFactory.cpp.

5  : SystemID(1), GlobalID(1){
6  Instance = this;
7 }

◆ ~IDFactory()

IDFactory::~IDFactory ( )

Definition at line 8 of file IDFactory.cpp.

8  {
9  Instance = NULL;
10 }

Member Function Documentation

◆ Get()

DLLEXPORT IDFactory * Leviathan::IDFactory::Get ( )
static

Definition at line 14 of file IDFactory.cpp.

14  {
15 
16  return Instance;
17 }

◆ GetID()

static int Leviathan::IDFactory::GetID ( )
inlinestatic

Definition at line 17 of file IDFactory.h.

17  {
18 
19  return Instance->ProduceID();
20  }
DLLEXPORT int ProduceID()
Definition: IDFactory.cpp:19

◆ GetSystemID()

static int Leviathan::IDFactory::GetSystemID ( )
inlinestatic

Definition at line 22 of file IDFactory.h.

22  {
23 
24  return Instance->ProduceSystemID();
25  }
DLLEXPORT int ProduceSystemID()
Definition: IDFactory.cpp:31

◆ ProduceID()

DLLEXPORT int IDFactory::ProduceID ( )

Definition at line 19 of file IDFactory.cpp.

19  {
20 
21  const auto result = GlobalID.fetch_add(1, std::memory_order_relaxed);
22 
23  if(result == INT_MAX){
24 
25  Logger::Get()->Error("IDFactory ID overflow");
26  }
27 
28  return result;
29 }
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
DLLEXPORT void Error(const std::string &data) override
Definition: Logger.cpp:177

◆ ProduceSystemID()

DLLEXPORT int IDFactory::ProduceSystemID ( )

Definition at line 31 of file IDFactory.cpp.

31  {
32 
33  const auto result = SystemID.fetch_add(1, std::memory_order_relaxed);
34 
35  if(result == INT_MAX){
36 
37  Logger::Get()->Error("IDFactory system ID overflow");
38  }
39 
40  return result;
41 }
static DLLEXPORT Logger * Get()
Definition: Logger.cpp:106
DLLEXPORT void Error(const std::string &data) override
Definition: Logger.cpp:177

The documentation for this class was generated from the following files: