Files
NazaraEngine/include/Nazara/Core/RefCounted.hpp
Lynix 07725ceb03 Core/RefCounted: Remove persistent boolean
Former-commit-id: 99602e0fa1e54b6fc8e0087ef89d0e2c74bcfc15 [formerly 83374368c28b83e4916958e7a58d54ec663a9842]
Former-commit-id: 603d0c81eada7d1f25058163bbf97672cd96d08c
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