git mv Code\Sandbox\Editor Code/Editor
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : Reference counted base object.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
|
||||
#define CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
|
||||
#pragma once
|
||||
|
||||
#include <Include/EditorCoreAPI.h>
|
||||
|
||||
//! Derive from this class to get reference counting in your class.
|
||||
class EDITOR_CORE_API CRefCountBase
|
||||
{
|
||||
public:
|
||||
CRefCountBase() {}
|
||||
|
||||
//! Add a new reference to this object.
|
||||
int AddRef()
|
||||
{
|
||||
m_nRefCount++;
|
||||
return m_nRefCount;
|
||||
}
|
||||
|
||||
//! Release reference to this object.
|
||||
//! When the reference count reaches zero, the object is deleted.
|
||||
int Release()
|
||||
{
|
||||
int refs = --m_nRefCount;
|
||||
if (m_nRefCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
else if (m_nRefCount < 0)
|
||||
{
|
||||
CryFatalError("Negative ref count");
|
||||
}
|
||||
return refs;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~CRefCountBase() {}
|
||||
|
||||
private:
|
||||
int m_nRefCount = 0;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_UTIL_REFCOUNTBASE_H
|
||||
Reference in New Issue
Block a user