Files
NazaraEngine/include/Nazara/Core/RefCounted.hpp
Lynix 755bf0b04b Core/RefCounted: Remove persistent boolean
Former-commit-id: 6661b29e0e5e1dee8f4588688dc42865ce76e9ba [formerly 55e47c5ec3851e55243fb0e8e85d7fcc22f6cc1b]
Former-commit-id: 5442ab91a3a4b7da93c10bd06889785ac1faf034
2016-08-02 12:52:49 +02:00

45 lines
988 B
C++

// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_REFCOUNTED_HPP
#define NAZARA_REFCOUNTED_HPP
#include <Nazara/Prerequesites.hpp>
#include <atomic>
#include <unordered_map>
#if NAZARA_CORE_THREADSAFE && NAZARA_THREADSAFETY_REFCOUNTED
#include <Nazara/Core/ThreadSafety.hpp>
#else
#include <Nazara/Core/ThreadSafetyOff.hpp>
#endif
namespace Nz
{
class NAZARA_CORE_API RefCounted
{
public:
RefCounted();
RefCounted(const RefCounted&) = delete;
RefCounted(RefCounted&&) = default;
virtual ~RefCounted();
void AddReference() const;
unsigned int GetReferenceCount() const;
bool RemoveReference() const;
RefCounted& operator=(const RefCounted&) = delete;
RefCounted& operator=(RefCounted&&) = default;
private:
mutable std::atomic_uint m_referenceCount;
};
}
#endif // NAZARA_RESOURCE_HPP